Re: Cocoa Newbie Thread/Memory Problems
On Mar 16, 2010, at 4:38 PM, Dave wrote: > - (NSString*)makeURLString:(NString*) theBaseURL ForDate:(NSDate*)theDate > UsingDatabse:(NString*) theDatabaseType Dave, Does it matter that UsingDatabse is misspelled ? Good Luck, Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Programmatically binding Core Data to dynamic NSTableColumns
On Mar 17, 2010, at 12:59 PM, Michael LaMorte wrote: > I have a Core Data application with two entities: Item and Entries. Item has > a dataType string variable. Item has a to-many inverse relationship to > Entries. Entries has two variables: stringData and numberData. > > I'm programmatically creating an NSTableColumn for each Item. The cell type > of the column is defined by the Item's dataType variable. This part is > working. > > The goal is for each Item to have a column, and when clicking an Add New > Entry button, a new Entry is created for each Item. The interface would add > one row, with the value bound to the corresponding stringData or numberData > for the Entry for that Item. > > Right now, the Add New Entry button/method loops through the Items and > creates a new Entry for each... that's working okay. Where I'm having > problems is figuring out the bindings to properly display the columns. The > bind statement I'm using is: > > [itemColumn bind:@"value" toObject:entryArrayController > withKeyPath:@"arrangedObjects.numberData" options:nil]; if you are using a loop > arrangedObjects.numberData wont work. See if [5302] below helps... I extract the fieldnames from a tab delimited file, thus the reason for the variable names for(NSString *tabDelimitedFieldName in theFieldNames) { // See NOTE : [5301] NSTableColumn *aColumn = [[[NSTableColumn alloc] initWithIdentifier:tabDelimitedFieldName] autorelease]; NSString *tabDelimitedFieldNameCapitalized = [[tabDelimitedFieldName stringByReplacingOccurrencesOfString:@"_" withString:@" "] capitalizedString]; [[aColumn headerCell] setStringValue:tabDelimitedFieldNameCapitalized]; [aColumn setWidth:(CGFloat)93.0]; // [5302] This next line is key NSString *theString = [NSString stringWithFormat:@"arrangedObjects.%@",tabDelimitedFieldName]; [aColumn bind:NSValueBinding toObject:(id)theArrayController withKeyPath:theString options:nil]; [theUserInterfaceTableView addTableColumn:aColumn]; } > (It's in an if statement, so it binds to either numberData or stringData as > appropriate.) > > This results in 1 row being added for each Item, and the entire row is bound > to the same value. So if I have 6 Items, I correctly have 6 columns (one for > each Item) but clicking Add New Entry it incorrectly generates 6 rows, one > for each Item. > > I've tried many variations of the toObject and withKeyPath: values to no > avail. I've looked through all the Key Value Coding and other Apple dev > documentation and Googled like mad, but after 3 unproductive days I'm hoping > someone here can help. Bill Hernandez Plano, Texas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Programmatically binding Core Data to dynamic NSTableColumns
On Mar 17, 2010, at 2:17 PM, Bill Hernandez wrote: >> (It's in an if statement, so it binds to either numberData or stringData as >> appropriate.) > Michael, Sorry I missed the part about the if statement... I am running into a similar problem, the log shows the data (array of dictionaries), but I cannot seem to get the data to display in the NSTableView... Best of Luck, Bill Hernandez Plano, Texas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSComboBox problem in 10.6.2
On Mar 19, 2010, at 7:31 AM, Jim Correia wrote: >> uncaught exception 'NSRangeException', reason: '*** -[NSCFArray >> objectAtIndex:]: index (-1 (or possibly larger)) beyond bounds (5)' I was running into something similar this morning, and I traced it back to the fact that I had set the type of a variable to NSUInteger, and the return value, when I lloked up the class docs, was actually NSInteger Something like NSUInteger rowIndex = [tableView selectedRow]; and when I traced through using the debugger I found the mismatch. I don't know if you might be having the same problem, but you might take a quick look... Best of luck, Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSComboBox problem in 10.6.2
H. Miersch wrote, >> uncaught exception 'NSRangeException', reason: '*** -[NSCFArray >> objectAtIndex:]: index (-1 (or possibly larger)) beyond bounds (5)' I was running into something similar this morning, and I traced it back to the fact that I had set the type of a variable to NSUInteger, and the return value, when I lloked up the class docs, was actually NSInteger. Something like : NSUInteger rowIndex = [tableView selectedRow]; forgot to include this earlier, should have been : NSInteger rowIndex = [tableView selectedRow]; and when I traced through using the debugger I found the mismatch. I don't know if you might be having the same problem, but you might take a quick look... Best of luck, Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSComboBox problem in 10.6.2
On Mar 19, 2010, at 8:45 AM, H. Miersch wrote: > My theory is that there's something wrong with the array. Either it isn't > initialized properly or the methods can't access it or something. Gonna try > self.symbols instead of symbols, see if that changes anything... Another thing I forgot to ask : are you using C or Cocoa arrays ? I kept running into some crashes, and traced them back to where I was using C arrays. I converted them to Cocoa arrays and everything got solved, the problems went away. I don't know if this has anything to do with your problems, but it was just something I ran into. Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
applicationShouldTerminateAfterLastWindowClosed Document-based Project Help?
I had posted this message at http://discussions.apple.com/thread.jspa?threadID=2374717&tstart=0 but thought I might have better luck here. If I do the following: ( 1 ) create a NON-document based Cocoa Project: ( 2 ) add a button to the nib window, name it DONE ( 3 ) Control Click and Drag from DONE to the Window and select performClose: from the HUD ( 4 ) Run and click on DONE and applicationShouldTerminateAfterLastWindowClosed gets called, and the app quits just like it is supposed to. So this brief amount of code works GOOD ... But if I try to get this to work with a Document based Project I cannot get applicationShouldTerminateAfterLastWindowClosed to trigger such that the application will quit. I have tried creating an AppController Class (SubClass of NSController) then dragged it to the Nib Window, auto-created the AppController methods, and put the code there, and IB will not let me Control-Click-Drag from the File's Owner to the AppController instance in the Nib. The AppController won't highlight. So obviously I am doing something wrong... // TestNoDocAppDelegate.h // TestNoDoc #import @interface TestNoDocAppDelegate : NSObject { NSWindow *window; } @property (assign) IBOutlet NSWindow *window; @end // TestNoDocAppDelegate.m // TestNoDoc #import "TestNoDocAppDelegate.h" @implementation TestNoDocAppDelegate @synthesize window; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Insert code here to initialize your application } // If the user closes the last window in the application, make sure the application quits. - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender { NSLog(@"[4567] %@",@"applicationShouldTerminateAfterLastWindowClosed"); return YES; } @end When I tried this awakeFromNib in MyDocument Class I still could not get applicationShouldTerminateAfterLastWindowClosed to trigger. - (void) awakeFromNib { NSLog(@"[4001] %@",[NSApp delegate]); // returned null [NSApp setDelegate:self]; [[NSApp delegate] applicationShouldTerminateAfterLastWindowClosed:NSApp]; // this got called OK NSLog(@"[4002] %@",[NSApp delegate]); // returned non-null value (whether it was good or not, I don't know. I assume it was.) } I am missing something with either not having the right class, or probably with the Nib Window connections. I'd be grateful for some help. Bill Hernandez Plano, Texas Steve Herman1 wrote: So, instantiate a DocAppDelegate object in the MainMenu.xib instead. The File's Owner in that file represents the application so you can control drag from there to your delegate object. . . I tried this and umpteen different combinations, and finally gave up. I know there's got to be a way to have the application respond to delegate methods, I just haven't found anything that shows how to get a document based project to respond to applicationShouldTerminateAfterLastWindowClosed. . . PS - I tried creating my delegate object in MyDocument.xib and the control-dragging from the "Application" object to my delegate. That seems to work in IB and allowed me to make the connection, but when I built and ran the app it would crash when the last window closed... I'm not sure what the difference is between that object and the "File's Owner" or the "Application" object in in MainMenu.xib (both of which worked). . I ran into the same crashes. Maybe someone will come up with an answer... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: applicationShouldTerminateAfterLastWindowClosed Document-based Project Help?
On Mar 23, 2010, at 12:27 PM, Quincey Morris wrote: > There's quite a lot of flailing going on here. If something goes wrong, > randomly trying to solve a different problem isn't a great strategy. You are absolutely right on every one of your points, really on the money. I've been trying to learn Cocoa over the past three months, and every time I think I am making headway, I run into a problem and there's nobody locally to ask. I've bought several books on Cocoa, and have been trying to read them but my impatience gets the better of me, and I want to build stuff for which I am not equipped yet. I should do more reading and less coding... > You have an IB *usability* problem. That is, you tried to do something in IB > and it didn't behave as expected. [As a consequence, your application has no > delegate, and therefore -- of course -- the application delegate method > applicationShouldTerminateAfterLastWindowClosed doesn't get called.] > > So, back to IB. You don't say *which* nib you added your AppController > instance to. My guess is that you're trying to do this in a document window > nib (where File's Owner is of type NSDocument or NSWindowController) instead > of the main menu nib. If that's not it, then what is the class of File's > Owner? If you select File's Owner and display the Connections tab of the IB > inspector, can you drag from the circle next to the 'delegate' outlet to your > AppController object? To any object at all? I had a severe misconception, which is that I didn't realize that I should be creating the AppController in the MainMenu nib. I honestly thought that MainMenu.xib was only for the menus. I had no clue that I should have put the AppController there, I was working with the NSDocument nib. Now it all makes sense. What an enlightening event... > Also, this is not what you were asking about, and really none of my business, > but why on earth do you want a document-based app to close after its last > window closes? It denies the user the opportunity to open or create a new > document. You are absolutely right ! The only reason for the applicationShouldTerminateAfterLastWindowClosed was to save me a step every time I used Build and Run and then closed a window. Instead of doing s CMD-Q, or clicking on the red Tasks button to get back to the project, I just started putting a Done button, it was just as a matter of convenience while I am trying to proceed on the learning curve. I had not even considered, or thought about the user yet. I am still in the totally confused stage, every time I think I am making headway, I realize I am not... > Also, regarding your original non-document-based project, even if it was just > a throw-away exercise, don't label your button "DONE". I mean this is > torturing kittens, or worse. Mac buttons (except for "OK") aren't in > uppercase, and the button label should say what it's going to do. "Quit" > would have been perfect for this application, I suspect, and just as easy for > you to type. :) You are right once again, I had actually written the message using Done, instead of DONE, the first time I posted it, but I was really trying to draw attention to the button so I changed it to DONE. I had posted a number of questions on another forum, and never got much in the way of replies. Sometimes days would go by, and I could tell that many people had read the posts, but no replies were forthcoming. Sometimes it got pretty discouraging, and a couple of days ago I found out about this forum, and this was my first post. Thank You very much for taking the time to provide your insights and help... Bill Hernandez Plano, Texas http://www.journey-of-flight.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Tooltips over buttons ?
I've looked for a couple of hours trying to find a simple example on how to implement tooltips over three graphic buttons. I just want to do something simple like show what they do. {add, insert, modify, delete, print, etc}. Actually you can tell pretty much what all the icons do except for the insert. It is a nice icon, and I don't want to change it, I would just like to try to do this if it is not a expert task. Most of the IB info I found during my search is very old. The manual didn't help me much, I am looking for an example if possible, if anybody knows of a recent one. Thanks for any help... Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Tooltips over buttons ?
On Mar 24, 2010, at 11:53 PM, Jerry Krinock wrote: > On 2010 Mar 24, at 21:10, Bill Hernandez wrote: > >> I've looked for a couple of hours trying to find a simple example on how to >> implement tooltips over three graphic buttons. > >> Most of the IB info I found during my search is very old. > >> I am looking for an example if possible > > Can't think of any examples, probably because this is so easy. But, if > you've never done it before, it's not easy. Here you go... > > Since you mentioned IB, we'll use bindings in your nib. > > First of all, pick an object which can provide the needed tooltip string, > that is accessible in the Bind to: popup menus in the Inspector in Interface > Builder, either directly or via a key path. Often this will be your app > delegate or window controller (File's Owner). Implement a method named > > -(NSString*)myToolTip ; > > which returns the string you want to see in the tooltip. > > Switch to Interface Builder, inspect the subject button, click Bindings tab, > scroll way down to the bottom and you'll see "ToolTip". Expand it. In the > popup, select the accessible object from above, and in Model Key Path paste > in that key path if any followed by a dot, ending with the method name > myToolTip. Jerry, Thank You so much... I have spent hours on this about a month ago, then again yesterday, and all I can say is that this is so incredibly cool. You are right, this is really simple, but I couldn't find an example anywhere, when I read the docs http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/OnlineHelp/Concepts/Tooltips.html I swear to you all they did was confuse me... TestNoDocAppDelegate.h -(NSString*)insertButtonToolTip ; TestNoDocAppDelegate.m -(NSString*) insertButtonToolTip { return @"This is the insert button"; } ( 1 ) In IB selected the <[Insert Button]> ( 2 ) hit CMD-4 ( 3 ) opened the Tooltips disclosure triangle ( 4 ) checked Bind to : TestNoDocAppDelegate ( 5 ) Model Key Path : insertButtonToolTip ... I like to use little image buttons, and now I finally have Tooltips, how incredibly awesome... I don't know if you can tell I am excited, or not. I don't want it to show ! I hope you have a great day ! Bill Hernandez Plano, Texas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Best book for learning Objective c and cocoa
I am fortunate to live within a few miles of Nerdbooks, and always look forward to trips that take me there. I am never disappointed, they always have a wonderful selection that you can actually browse through, and today's trip was no different. Since I mentioned them, I'll point out that they always sell at a substantial discount, and since most of their business is web based they operate out of a warehouse, but if you don't mind a warehouse, which I don't, it is a great place to visit. I am in no way related to, etc, etc. I am a happy customer. All that having been said, they had several new books (published 2010) , and I bought three. I almost didn't buy the one by Bill Cheeseman, because as I scanned through it, it didn't have as many images as the others. Boy, what a huge mistake that would have been. When I got home, I started reading "Cocoa Recipes for Mac OS X", and within a few pages, I had absolutely fallen in love with this book, and with Bill Cheeseman's gifted writing style. I always use more images than text when documenting anything, because I tend to write poorly. I never take the time to proofread, and to this day when I type, I look at the keyboard instead the screen. Never have mastered this process. So I tend to look for books that have more images, because that is the style I am used to... In my case, I figure that if I do screen capture with minimal text I minimize the typos I introduce in my un-proofed documents. I personally buy tons of books, most of the time I will read parts of them, and at some point something is not explained well enough to suit me, and they end up becoming a reference. I always know when this is going to happen, because I start jumping ahead. I think because Bill Cheeseman is in fact so gifted at writing, and explains things so well, this is going to be a really great book. I am very excited to have found it, and if you hadn't asked the question, I would have not made the trip to Nerdbooks, and would have missed this book. Boy, talk about the "Butterfly Effect". Best Regards, Bill Hernandez Plano, Texas On Mar 31, 2010, at 7:20 AM, Nikhil Khandelwal wrote: > I am looking for books to learn Objective C and Cocoa. I have good knowledge > of oo programming. Also I did a lot of work with Objective C and Cocoa using > API's and reading through documentation. Please suggest some name of good > books for knowing Objective C and Cocoa deeper. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSNumberFormatter not working for me ?
I am calling a method that I pass a phone number string "1234567890" and should return "(123) 456-7890" but sure enough, that is not what is happening... Any Ideas ? Bil Hernandez Plano, Texas I created a simple demo below : $ clang_gen ---> shows : ** BUILD SUCCEEDED ** Build and Analyze shows : ---> Build Succeeded ---> No Issues NSLog shows : Switching to process 2491 Running… (gdb) continue Current language: auto; currently objective-c 2010-04-13 15:04:01.829 Formatter2491:a0f 4625 theString = 1234567890 2010-04-13 15:04:01.832 Formatter2491:a0f 4626 phoneNumber = 1234567890 kill quit The Debugger has exited with status 0. // +-+-+-+-+-+-+-+-+ // BHFormatter.h // +-+-+-+-+-+-+-+-+ #import @interface BHFormatter : NSObject { } @end // +-+-+-+-+-+-+-+-+ // BHFormatter.m // +-+-+-+-+-+-+-+-+ #import "BHFormatter.h" #import "BHUtility.h" @implementation BHFormatter // +-+-+-+-+-+-+-+-+ - (void)awakeFromNib { // I have already run a routine to strip all non digits by this time NSString *strippedNumber = @"1234567890"; NSString *phoneNumber; phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:@"(###) ###-"]; NSLog(@"[4626] phoneNumber = %@", phoneNumber); } // +-+-+-+-+-+-+-+-+ @end // +-+-+-+-+-+-+-+-+ // BHUtility.h // +-+-+-+-+-+-+-+-+ #import @interface BHUtility : NSObject { } + (NSString *)bhFormatNumberString:(NSString *)aNumberString withFormat:(NSString *)aFormat; @end // +-+-+-+-+-+-+-+-+ // BHUtility.m // +-+-+-+-+-+-+-+-+ #import "BHUtility.h" @implementation BHUtility // +-+-+-+-+-+-+-+-+ + (NSString *)bhFormatNumberString:(NSString *)aNumberString withFormat:(NSString *)aFormat { NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; // NSFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; [numberFormatter setFormat:aFormat];// specify just positive values format NSInteger theInt = [aNumberString intValue]; NSNumber *theNum = [NSNumber numberWithInt:theInt]; NSString *theString = (NSString *)[numberFormatter stringFromNumber:theNum]; NSLog(@"[4625] theString = %@", theString); return theString; // +-+-+-+-+-+-+-+-+ } @end ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSNumberFormatter not working for me ?
On Apr 13, 2010, at 5:18 PM, Keary Suska wrote: > Sorry, I missed that. Anyway, it may be because the format is being > interpreted using 10.4 behavior, in which case the format may not be valid > and may be ignored. Have you tried single-quoting all non-hash marks (pound > signs) to eliminate their special significance? > > You may need to watch out for integer overflow issues as well, if you are > targeting 32bit systems. > > Keary Suska Keary, // +-+-+-+-+-+-+-+-+ - (void)awakeFromNib { // I have already run a routine to strip all non digits by this time NSString *strippedNumber = @"1234567890"; NSString *phoneNumber; phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:@"'('###')' ###'-'"]; NSLog(@"[4626] phoneNumber = %@", phoneNumber); } // +-+-+-+-+-+-+-+-+ I tried changing the format to @"'('###')' ###'-'" but the results were the same. Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSNumberFormatter not working for me ?
On Apr 13, 2010, at 5:39 PM, Keary Suska wrote: > I think the issue remains that the format you are passing is not considered a > valid format, and is getting ignored. You can confirm this by providing a > valid number format for comparison. I tend to use a custom formatter for this > purpose, keeping the phone number as a string. It is more robust and allows > for non-U.S. number that may begin with 0. Keary, I can do the following : // +-+-+-+-+-+-+-+-+ - (void)awakeFromNib { // I have already run a routine to strip all non digits by this time NSString *strippedNumber = @"1234567890"; NSString *phoneNumber; BOOL useFormatter = NO; if(useFormatter) { phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:@"(###) ###-"]; } else { if([strippedNumber length] == 10) { NSString *areacode = [strippedNumber substringWithRange:NSMakeRange(0, 3)]; NSString *exchange = [strippedNumber substringWithRange:NSMakeRange(3, 3)]; NSString *number = [strippedNumber substringWithRange:NSMakeRange(6, 4)]; phoneNumber = [NSString stringWithFormat:@"(%@) %...@-%@", areacode, exchange, number]; } else { phoneNumber = strippedNumber; } } NSLog(@"[4626] phoneNumber = %@", phoneNumber); } // +-+-+-+-+-+-+-+-+ but this was part of learning another little piece of Cocoa. I started trying to learn a little Cocoa around the end of the year,I think December, and have come a long way, but every time I think I am making progress I realize it is going to take a long time... Thanks for trying to help... Bill Hernandez Plano, Texas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSNumberFormatter not working for me ?
On Apr 13, 2010, at 5:50 PM, Murat Konar wrote: > For one thing, the docs say that -setFormat: is for use with formatters using > NSNumberFormatterBehavior10_0 behavior. > > Have you set the formatters behavior? murat, No, just the way the code showed. Here's from the docs : -- From what I can see it should work out or the box ??? NSNumberFormatterBehavior10_0 The number-formatter behavior as it existed prior to Mac OS X v10.4. Available in Mac OS X v10.4 and later. Bill Hernandez Plano, Texas Here's the rest... NSNumberFormatterBehaviorDefault The number-formatter behavior set as the default for new instances. You can set the default formatter behavior with the class methodsetDefaultFormatterBehavior:. Available in Mac OS X v10.4 and later. Declared in NSNumberFormatter.h. NSNumberFormatterBehavior10_0 The number-formatter behavior as it existed prior to Mac OS X v10.4. Available in Mac OS X v10.4 and later. Declared in NSNumberFormatter.h. NSNumberFormatterBehavior10_4 The number-formatter behavior since Mac OS X v10.4. Available in Mac OS X v10.4 and later. Declared in NSNumberFormatter.h. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSNumberFormatter not working for me ?
On Apr 13, 2010, at 6:01 PM, Kyle Sluder wrote: > Things like phone numbers, zip codes, and order numbers aren't really > numbers. They're labels composed of digits. Numbers are typically > useful for quantities, and that's where number formatters are > appropriate. Custom formatters that convert from strings to strings > are the more appropriate choice for telephone numbers and the like. Kyle, Even so, I converted the string to an NSNumber and used the formatter against a number, not a string. I did something similar using the NSDateFormatter to convert dates, and that went very smooth. Used almost identical format functions except using dates, instead of numbers, and they worked as expected... Puzzled ? Bill Hernandez Plano, Texas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSNumberFormatter not working for me ?
On Apr 13, 2010, at 5:50 PM, Murat Konar wrote: > For one thing, the docs say that -setFormat: is for use with formatters using > NSNumberFormatterBehavior10_0 behavior. > > Have you set the formatters behavior? murat, No, just the way the code showed. Here's from the docs : -- From what I can see it should work out or the box ??? NSNumberFormatterBehavior10_0 The number-formatter behavior as it existed prior to Mac OS X v10.4. Available in Mac OS X v10.4 and later. I added : [NSNumberFormatter setDefaultFormatterBehavior:NSNumberFormatterBehavior10_0]; but it didn't help... // +-+-+-+-+-+-+-+-+ + (NSString *)bhFormatNumberString:(NSString *)aNumberString withFormat:(NSString *)aFormat { NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; [NSNumberFormatter setDefaultFormatterBehavior:NSNumberFormatterBehavior10_0]; [numberFormatter setFormat:aFormat];// specify just positive values format NSInteger theInt = [aNumberString intValue]; NSNumber *theNum = [NSNumber numberWithInt:theInt]; NSString *theString = (NSString *)[numberFormatter stringFromNumber:theNum]; NSLog(@"[4625] theString = %@", theString); return theString; // +-+-+-+-+-+-----+-----+-+ } Bill Hernandez Plano, Texas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSNumberFormatter not working for me ? [SOLVED]
This is a great forum, I can't believe all the people that pitched in to help... Thanks everybody for all the time and help... This is actually a really nice number formatting method that will go in my BHUtility.m You can format any way you want Notice that the first three results are 10 digits, after I had stripped out all non-digits, and the fourth example contains 14 digits after all the junk chars are stripped out. I wrote a couple of methods that strip out leading, trailing spaces, converts multiple spaces to single spaces. The formatters also do capitalization after cleanup, convert middle names to capitalized middle initials with a period on the end, convert state names to short state initials, etc. In this case the formatter strips out everything except digits If anybody is interested in these formatter methods, I can post them. Thanks again, Bill Hernandez Plano, Texas RESULTS: Loading program into debugger… Program loaded. run [Switching to process 6148] Running… 2010-04-13 22:29:15.777 Formatter[6261:a0f] [4626] returnString = (123) 456-7890 2010-04-13 22:29:15.779 Formatter[6261:a0f] [4626] returnString = 123.456.7890 2010-04-13 22:29:15.779 Formatter[6261:a0f] [4626] returnString = <[123.456.7890]> 2010-04-13 22:29:15.780 Formatter[6261:a0f] [4626] returnString = (123) 456-7890 [extension 1234] kill quit The Debugger has exited with status 0. // +-+-+-+-+-+-+-+-+ - (void)awakeFromNib { // I have already run a routine to strip all non digits by this time NSString *strippedNumber = @"1234567890"; NSString *phoneNumber; BOOL useFormatter = YES; if(useFormatter) { phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:@"(###) ###-"]; phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:@"###.###."]; phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:@"<[###.###.]>"]; strippedNumber = @"12345678901234";// notice this is 14 digits long now if([strippedNumber length] == 14) { phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:@"(###) ###- [extension ]"]; } else { phoneNumber = strippedNumber; } } else { // THIS IS NOT VERY FLEXIBLE if([strippedNumber length] == 10) { NSString *areacode = [strippedNumber substringWithRange:NSMakeRange(0, 3)]; NSString *exchange = [strippedNumber substringWithRange:NSMakeRange(3, 3)]; NSString *number = [strippedNumber substringWithRange:NSMakeRange(6, 4)]; phoneNumber = [NSString stringWithFormat:@"(%@) %...@-%@", areacode, exchange, number]; } else { phoneNumber = strippedNumber; } } NSLog(@"[4626] phoneNumber = %@", phoneNumber); } // +-+-+-+-+-+-+-+-+ // +-+-+-+-+-+-+-+-+ + (NSString *)bhFormatNumberString:(NSString *)aNumberString withFormat:(NSString *)aFormat { NSString *myFormatString = [[NSString stringWithString:aFormat] copy]; NSUInteger myFormatStringLength = [myFormatString length]; NSMutableString *returnString = [[[NSMutableString alloc] initWithCapacity:myFormatStringLength] autorelease]; NSUInteger i = 0;// i represents the myFormatString character position/counter through the loop NSUInteger aNumberStringPosition = 0; unichar myUniChar; for ( i = 0; i < myFormatStringLength; i ++ ) { myUniChar = [myFormatString characterAtIndex:i]; // NSLog (@"[4525] i = %i: myUniChar = %C\n", i, myUniChar); if (myUniChar == '#') { // aNumberStringPosition += 1; myUniChar = [aNumberString characterAtIndex:aNumberStringPosition++]; } [returnString appendFormat:@"%C",myUniChar]; } NSLog(@"[4626] returnString = %@", returnString); return returnString; } // +-+-+-+-+-+-+-+-+ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSNumberFormatter not working for me ?
On Apr 13, 2010, at 8:09 PM, Murat Konar wrote: > If you don't explicitly set a formatter behavior, you are probably getting > the newest behavior "NSNumberFormatterBehavior10_4", and -setFormat: does > require the older "NSNumberFormatterBehavior10_0" behavior. That's why your > string is being returned unchanged. As far as the formatter is concerned, you > have not set a format string. > > Note also that in your most recently posted code, you set the default > behavior for the class *after* you allocate an instance. You should either > set the default behavior before creating an instance, or set the behavior on > the instance itself. murat, if I call: phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:@"(###) ###-"]; run [Switching to process 6314] Running… Current language: auto; currently objective-c 2010-04-13 22:48:23.398 Formatter[6314:a0f] [4625] theString = (1234567890) - (gdb) // +-+-+-+-+-+-+-+-+ + (NSString *)bhFormatNumberString:(NSString *)aNumberString withFormat:(NSString *)aFormat { // THIS METHOD DOES NOT WORK [NSNumberFormatter setDefaultFormatterBehavior:NSNumberFormatterBehavior10_0]; NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; // NSFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; [numberFormatter setFormat:aFormat];// specify just positive values format NSInteger theInt = [aNumberString intValue]; NSNumber *theNum = [NSNumber numberWithInt:theInt]; NSString *theString = (NSString *)[numberFormatter stringFromNumber:theNum]; NSLog(@"[4625] theString = %@", theString); return theString; // +-+-+-+-+-+-+-+-+ } I came up with a better work-aroundthat I posted to the forum. Take a look at it, it really works very well, and is not limited to phone numbers. Thanks a million for trying to help me... Bill Hernandez Plano, Texas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSNumberFormatter not working for me ?
On Apr 14, 2010, at 1:04 PM, Murat Konar wrote: > Actually, setting the formatter behavior does work (it does allow you to use > setFormat: to set a format string). The remaining problem is that I don't > think NSNumberFormatter allows the arbitray digit-by-digit formatting of > numbers that you expect. > > _murat murat, Thank You for your effort... The result that setting : [NSNumberFormatter setDefaultFormatterBehavior:NSNumberFormatterBehavior10_0]; is shown on the next line, hardly what one would expect ? > (1234567890) - I've worked with lots of number formatters over the years, and that is what they do, format numbers into strings, any kind of string... I looked at the header file for NSNumberFormatter, and there seem to be 9,000,000+ methods, it is amazing. Buried in there, there has to be a simple way to format a string, that I am overlooking ? If you look the simple formatter I wrote up last night, it will format a string digits any way imaginable. I just ran the little test app I created last night and you can see the results below : I use 'strippedNumber', because by the time I call this routine all the junk non-digits have been stripped out... Bill Hernandez Plano, Texas I created a simple NSTextView that the output gets sent to: IBOutlet NSTextView *mainTextView; CALLED : NSString *phoneNumber; phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:format]; [4751] strippedNumber = @"1234567890" format = @"(###) ###-" result = @"(123) 456-7890" [4752] strippedNumber = @"1234567890" format = @"###.###." result = @"123.456.7890" [4753] strippedNumber = @"1234567890" format = @"<[###.###.]>" result = @"<[123.456.7890]>" [4754] strippedNumber = @"12345678909889" format = @"(###) ###- [extension ]" result = @"(123) 456-7890 [extension 9889]" [4755] strippedNumber = @"12345678909889" format = @"Weekends : (###) ###- [extension ]" result = @"Weekends : (123) 456-7890 [extension 9889]" [4756] strippedNumber = @"12345678909889" format = @"Social Security : ###-##-###" result = @"Social Security : 123-45-678" You can see on the line above, that if the user enters more digits, than the format requires, the method simply skips the rest. This could be good and bad, but you can trap for that ahead of time... I would think the Apple Engineers could have come up with one more method, and had 9,000,001 in the class as a last resort. I bet the answer is in that class, I just can't find it, and I don't know enough Cocoa to come out of the rain. I am sure an answer will turn up... I also understand that I don't have big time error checking. and for me, this only has to work in a very limited scope, and does not need to be as robust as what comes from the factory. All that having been said, the work-around works really slick... I am sure that I am just overlooking something really simple, but I can't figure out what it is... // +-+-+-+-+-+-+-+-+ // BHUtility.h // Formatter // // Created by Bill Hernandez on 4/13/2010. // +-+-+-+-+-+-+-+-+ #import #import "RegexKitLite.h"// Not required for this demo, you can comment it out @interface BHUtility : NSObject { } // +-+-+-+-+-+-+-+-+ // [4827] ( BEGIN ) Working with Strings // +-+-+-+-+-+-+-+-+ /* * THIS METHOD DOES NOT WORK, NOTICE IT HAS BEEN RENAMED AS UNUSABLE (FOR NOW) * * I left it here in case NSNumberFormatter and setFormat ever work in this area * I couldn't figure out how to make it work, so I came up with a great work-around * at least in my opinion, doesn't sound very humble, I apologize for that... * * But in reality, it is a heck of a lot easier than using NSNumberFormatter, and * that's a fact... */ + (NSString *)unusable_bhFormatNumberString:(NSString *)aNumberString withFormat:(NSString *)aFormat; // +-+-+-+-+-+-+-+-+ /* * THIS IS THE MAIN NUMBER FORMATTER * * A less cryptic Objective CLike method, does the same as below, * this is more for the mere mortal Objective C afficionado... */ + (NSString *)bhFormatNumberString:(NSString *)aNumberString withFormat:(NSString *)aFormat; // +-+-+-+-+-+-+-+-+ /* * A more cryptic CLike method, does the
Re: NSNumberFormatter not working for me ?
On Apr 14, 2010, at 5:25 PM, Greg Guerin wrote: > Your code formats strings (more specifically, characters in strings). It > does not format numbers, as such. This is the work-around that I did because I could not make do with NSNumberFormatter. > By "number" I mean a binary numeric value (floating-point or integer), or > possibly NSNumber or NSDecimalNumber. I've been programming the mac since 1987 pretty much full-time. so I promise you, I am not confused at all about what a number is, and isn't... > All your "number" parameters are actually of the NSString* type, not of a > numeric type. The fact that the string contains digits is incidental. In a > sense, converting a numeric value to NSString* is already a "formatting" > operation, or at least a conversion operation. I think you missed the earlier messages. You are probably looking at the converter that I wrote as a work-around, which is basically a numeric string formatter. > Your code would work just as well if you passed it an alphabetic string, or > one containing punctuation marks. > > strippedNumber = @"SueMeTomorrow" > format = @"Social Security : ###-##-###" > result = @"Social Security : Sue-Me-Tom" > > I'm not saying the digit-string isn't relevant to what you're doing, only > that what you seem to think of as a number is, in fact, a string that happens > to contain a series of digit characters. I think that was a point an earlier > reply was trying to make: NSNumberFormatter is for numeric values (NSNumber, > in particular), not string values that happen to contain digits. I think you missed the previous message, where someone else made your same incorrect assumption, only to have that cleared up by Jens Alfke. Jens picked up that I was actually using an NSNumber with the NSNumberFormatter. Please look at the comment from Jens Alfke , and the three lines of code below, they should clear that up for you. > only that what you seem to think of as a number is I promise you I know what a number is... This got answered a while back... On Apr 13, 2010, at 4:55 PM, Jens Alfke wrote: > On Apr 13, 2010, at 2:49 PM, Keary Suska wrote: > >> You are asking the NSNumberFormatters to format a string, which it does not >> do (hence the class name). > > No he isn't. Viz: > > NSInteger theInt = [aNumberString intValue]; > NSNumber *theNum = [NSNumber numberWithInt:theInt]; > NSString *theString = (NSString *)[numberFormatter stringFromNumber:theNum]; > > —Jens Here's the original piece of code that you must have missed, please read the code carefully. I added two comments in the code in case you missed the NSNumber line. // <--- NSUInteger (look for these below) // <--- NSNumber (look for these below) // +-+-+-+-+-+-+-+-+ - (void)awakeFromNib { // I have already run a routine to strip all non digits by this time NSString *strippedNumber = @"1234567890"; NSString *phoneNumber; NSString *format; format = @"(###) ###-"; phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:format]; } // +-+-+-+-+-+-+-+-+ // +-+-+-+-+-+-+-+-+ + (NSString *)unusable_bhFormatNumberString:(NSString *)aNumberString withFormat:(NSString *)aFormat { // THIS METHOD DOES NOT WORK, WITH OR WITHOUT THE NEXT LINE // YIELDS INCORRECT RESULTS : @"(1234567890) -" [NSNumberFormatter setDefaultFormatterBehavior:NSNumberFormatterBehavior10_0]; NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; // NSFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; [numberFormatter setFormat:aFormat];// specify just positive values format NSUInteger theInt = [aNumberString intValue];// <--- NSUInteger NSNumber *theNum = [NSNumber numberWithInt:theInt];// <--- NSNumber NSString *theString = (NSString *)[numberFormatter stringFromNumber:theNum]; NSLog(@"[4625] theString = %@", theString); return theString; // +-+-+-+-+-+-+-+-+ } // +-+-+-+-+-+-+-+-+ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to a
Re: NSNumberFormatter not working for me ?
On Apr 15, 2010, at 12:14 PM, Murat Konar wrote: > On Apr 14, 2010, at 8:21 PM, Bill Hernandez wrote: > >> The point is that NSNumberFormatter appears to me missing some flexibility >> in dealing with other than its own set of formatting converters, whatever >> the programmers thought they would need at the time they wrote it. > > Well, yes, but I think we have an expectation mis-match problem. The > programmers had in mind a much smaller problem than the one you wish they did. > > Perhpas NSNumberFormatter could have been better named > (NSQuantityFormatter?), but I don't think NSNumberFormatter was ever > concieved of as being a one-stop solution for all numeric(ish) formatting. > There is no way to make a class perfectly general and suitable for all ways > of formatting arbitrary inputs. > > So you specialize based on what the input represents. For example, there is > another subclass of NSFormatter called NSDateFormatter which is specialized > to convert date objects to more friendly presentation strings. Obviously, > knowing that an input represents a date makes parsing it quite a bit simpler. > I wrote my own MIDI message formatter which takes MIDI messages, which are > represented as a sequence numbers, and presents them as either binary or > hexadecimal bytes. Again, the knowledge that the input is a MIDI message > makes converting it a lot easier. Murat, Funny, how you and I have come to some similar ideas... During the night I was thinking that with the limitations placed on NSNumberFormatter, compared to other num2string formatters I have used over time, it should have probably been called NSCurrencyDisplayFormatter, or something more limited than what NSNumberFormatter implies. Floating point vars know nothing about dollar signs, commas, etc. They are stored as a float internally, but are displayed in an NSTextField , or provided to a string, with either no string formatting as "43.75", or with some display formatting such as "$43.75". The point is that NSNumberFormatter appears to me missing some flexibility in dealing with other than its own set of formatting converters, whatever the programmers thought they would need at the time they wrote it. I looked at a the header file for the class and it is gigantic, it is an amazing piece of work. So even when you take numeric values from a couple of NSTextFields and perform some calculation, the display of those fields is purely string representation of the underlying values, but the minute you begin doing calculations, you are back working with the floats, ints, etc. Some systems handle this automatically for you, some require you to deal with that conversion, keeping track of what's what, etc. It's OK that the NSNumberFormatter doesn't have that capability, or at least that I havent found it, work-arounds have always been a specialty for me, so that doesn't bother me in the least, I was just trying to explore my way around Cocoa. The NSDateFormatter has worked very well for me, and showed no such weakness. As I mentioned before when displaying the {string, text} representation of the underlying {item, object} which could be {floats, doubles, ints, etc} the format is applied, and the result is used for display purposes, whether it be to the screen, printer, etc., and obviously the formatting does not change in any way the underlying object. Assuming there's a method to trigger the conversion, its job is to apply the format for conversion from object to display representation, and if you pass the method an NSNumber, and an NSNumberFormatter, then regardless of the source of that NSNumber, or its intended use, the result should be in the format that you provide. The formatter should not care, nor does it know anything about what the number is going to be used for, or where it came from. It does NOT know, whether you are going to use that number to {add, subtract, etc} or whatever. It's only function in life is to take a properly structured number in the form of an NSNumber Object, whether that NSNumber came from a phoneNumber string, a calculation, etc. It just doesn't matter, its source is irrelevant, and its target is also irrelevant. NSString *aNumberString = @"1234567890"; NSString *format = @"(###) ###-"; NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; [numberFormatter setFormat:format]; // specify just positive values format NSInteger theInt = [aNumberString intValue]; NSNumber *theNum = [NSNumber numberWithInt:theInt]; NSString *theResultString = (NSString *)[numberFormatter stringFromNumber:theNum]; The above should work, and the only way this scenario to fail is if there are additional assumptions/limitations, as to what is allowable within the format string, and with
Re: NSNumberFormatter not working for me ?
On Apr 15, 2010, at 1:38 PM, Chris Kane wrote: > I think people are confusing two issues, one being the abstract "phone > numbers aren't numbers and NSNumberFormatter is only for quantities", and the > other is the reason you don't get what you want out of NSNumberFormatter, in > trying to explain. Let me try to explain the latter as directly as possible. > > In this kind of example of the result you want: > >> format = @"(###) ###-" >> result = @"(123) 456-7890" > > You're trying to format a number object with NSNumberFormatter and get the > formatter to put junk in the middle of the number [digit sequence]. > NSNumberFormatter does not support formats putting junk in the middle of the > number, except for a limited set involving the thousands separator and the > decimal point. > > > You're already doing the right thing for what you want to do by writing your > own algorithm. You could mold that into the form of an NSFormatter subclass > then, if that is useful to you, or just keep it off to the side as a helper > function/method. > > Chris Kane > Cocoa Frameworks, Apple Chris, Thanks for stepping in... I had thought about some of this every time I woke up during the night, and began composing a message this morning that I just posted, in reference to my findings. I posted the message, checked the emails, and found your response, which agreed with my observations. In the end the string2num formatter NSNumberFormatter is more of a subset of a true number formatter, it really should be called a currency formatter, perhaps NSCurrencyFormatter, or NSCurrencyDisplayFormatter. Not that I care, now that I understand what its target audience, and its functional scope is. I was trying to use it within a broader scope than what it was designed for, and that is OK, I can certainly do workarounds. I just wanted to understand and use what was available instead of reinventing whatever... It took me a while to figure this out, because I am used to number2string formatters that handle currency, as well as custom formats of all types. Since I am learning the Cocoa Framework, I prefer to use what is available, but I also love and thrive on work-arounds... Thanks for clarifying and confirming my understanding... Bill Hernandez Plano, Texas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Avoid drawing in half pixel
Gustavo, I ran into this a few days ago when I was drawing a variable number of rectangles to a view, and found that the spacing was not always exact as one would expect. In my case the gist of it was that <[each unit]> in essence was a <[spacer + rectangleWidth]> someViewWidthRequired = <[spacer + rectangleWidth]> * <[number of units]> + <[endSpacer]> unfortunately <[someViewWidthRequired]> is not always equal to <[someViewWidthAvailable]> to figure out the initial rectangleWidth I used : w = (rect.size.width - ((noOfBoxes + 1) * spacerX))/noOfBoxes; Which if you convert : (w * noOfBoxes) + ((noOfBoxes + 1) * spacerX) = rect.size.width; rect.size.width = (w * noOfBoxes) + ((noOfBoxes * spacerX) + ( 1 * spacerX)); rect.size.width = (noOfBoxes * w) + (noOfBoxes * spacerX) + ( 1 * spacerX); rect.size.width = (noOfBoxes * (w + spacerX)) + ( 1 * spacerX); is the same as : someViewWidthRequired = <[spacer + rectangleWidth]> * <[number of units]> + <[endSpacer]> but unfortunately, when resizing the window, more often than not, there was a nonZero remainder. So while looping through to draw the rectangles, for the last one in the inner loop I made an adjustment to the last rectangle, which is not noticeable, rather than have the last spacer (endSpacer) look bad... if (this is the last rectangle in the inner loop, adjust its size so the spacer looks good) { w = (rect.size.width - ((noOfBoxes + 1) * spacerX) - (i * w)); } You are welcome to see how I handled this little dilemma at : http://discussions.apple.com/forum.jspa?forumID=728&start=0 The Topic: TUTORIAL: NSView flexible dynamic creation and loading of text and images The actual post : http://discussions.apple.com/thread.jspa?threadID=2421615&tstart=0 or you can download the project at : http://www.journey-of-flight.com Topic: Cocoa - Flexibility of Working with Views Shows how to create Cocoa - Objective C window views, and how to dynamically display text and images... Best Regards, Bill Hernandez Plano, Texas This is a piece of the method that handles the drawing : // +-+-+-+-+-+-+-+-+ - (void)drawRectDemo:(NSRect)rect { . . . . . . // +-+-+-+-+-+-+-+-+ // DEFINE AND INITIALIZE MAIN RECT VARIABLES // +-+-+-+-+-+-+-+-+ NSUInteger i = 0; // init the inner loop (column) counter NSUInteger j = 0; // init the outer loop (row) counter NSUInteger counter = 1;// init the counter for the total number of items NSRect boxRect;// declare a general purpose rectangle CGFloat x, y, w, h;// declare {origin, size} integer variables w = 99;// Init with bogus width, real width will be calculated below w = (rect.size.width - ((noOfBoxes + 1) * spacerX))/noOfBoxes; // +-+-+-+-+ // [5201] ( BEGIN ) outer loop (rows) // +-+-+-+-+ for( j = 0; j < noOfRows; j++) { if(useDynamicHeight) { h = (rect.size.height - (heightUsedByHeader + ((noOfRows + 1) * spacerY))); h = (h/noOfRows); } else { h = fixedBoxHeight; // if (useDynamicHeight == NO) {use fixed height} } // +-+-+-+-+-+-+-+-+ // var below is initialized, but not used for now, will possibly be used in future // +-+-+-+-+-+-+-+-+ x = spacerX; if(showHeaderBox) { y = heightUsedByHeader + ((j + 1 ) * spacerY) + (j * h); // leave (2 * spacerY) as fixed value } else { // These are both the same equation, but they are here in case // you want to do something different if the header {isShown, isNotShown} y = heightUsedByHeader + ((j + 1 ) * spacerY) + (j * h); // leave (2 * spacerY) as fixed value } // +-+-+-+-+ // [5202] ( BEGIN ) inner loop (columns) // +-+-+-+-+ for( i = 0; i < noOfBoxes; i++) { x = (spacerX * (i + 1)) + (w * i); if(adjustLastBoxForNonZeroRemainder) { if (i == (noOfBoxes - 1)) { /* // +-+-+-+-+-+-+-+-+ * Originally when I was trying to figure out how to do all this, I had used * NSUInteger instead of CGFloat vars for the rectangles, and that * caused an uneven last spacer. * * This solved that problem, and it actually worked very well. * It was after I had figured out thi
Re: Avoid drawing in half pixel
On May 6, 2010, at 9:00 AM, Bill Hernandez wrote: > // > +-+-+-+-+-+-+-+-+ > // DEFINE AND INITIALIZE MAIN RECT VARIABLES > // > +-+-+-+-+-+-+-+-+ > NSUInteger i = 0; // init the inner loop (column) counter > NSUInteger j = 0; // init the outer loop (row) counter > NSUInteger counter = 1;// init the counter for the total number of > items > > NSRect boxRect;// declare a general purpose rectangle > CGFloat x, y, w, h;// declare {origin, size} integer variables This should have been : // +-+-+-+-+-+-+-+-+ // DEFINE AND INITIALIZE MAIN RECT VARIABLES // +-+-+-+-+-+-+-+-+ NSUInteger i = 0; // init the inner loop (column) counter NSUInteger j = 0; // init the outer loop (row) counter NSUInteger counter = 1;// init the counter for the total number of items NSRect boxRect; // declare a general purpose rectangle // NSUInteger x, y, w, h; // declare {origin, size} integer variables CGFloat x, y, w, h; // declare {origin, size} float variables Sorry, I never updated the comment when I converted from NSUInteger to CGFloat Best, Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSBox sizeToFit problem
On May 6, 2010, at 10:07 AM, Jerry Krinock wrote: > Maybe all the objects in your nib have not been created yet. Try invoking > -sizeToFit in an -awakeFromNib method instead of > -applicationDidFinishLaunching. Even if it doesn't fix the problem, it's > still better. I ran into the same problem the other day and could not get it to work as I had hoped, so I gave up and did something different. I didn't reply earlier because I didn't have a solution, I just figured it was me. I thought "when I get time I'll have to try again..." Best Regards, Bill Hernandez Plano, Texas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSBox sizeToFit problem
On May 6, 2010, at 10:34 AM, Ingvar Nedrebo wrote: > But when trying that, I discovered that invoking sizeToFit twice in a row > does fit the box around its contents without clipping, but tightly -- i.e., > without any margins. I tried various permutations of sizeToFit and > setContentViewMargins but no difference: the margins are ignored. Curious. This is exactly what I ran into... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSPopupButtons work, but not in hierarchical mode, what am I missing here ?
Hi everybody, I have a hierarchical popup button that should allow me to select a row and column, both at the same time instead of having to use one popup menu for row, and one for column If for example, I select (row, col) = (4,2) as shown, as soon as the mouse is released the selected item goes back to (row, col) = (1,1) which is what was checked in IB. [ 1 ] [ 2 ] [ 3 ][ 1 ] [ 4 ] > [ 2 ] [ 5 ][ 3 ] [ 6 ][ 4 ] [ 7 ][ 5 ] [ 8 ][ 6 ] [ 7 ] [ 8 ] The regular (non hierMenus) popup buttons work great, the Action Methods trigger correctly, and the window is redrawn with the correct number of rows and columns. If you get a chance to look at it, the project download is at : http://www.journey-of-flight.com/bh_xcode/how-to/0150_Drawing_in_Views/index.php TIA, Bill Hernandez Plano, Texas http://www.journey-of-flight.com // MainView.h @interface MainView : NSView { // +-+-+-+-+-+-+-+-+ // Declare the instance variables // +-+-+-+-+-+-+-+-+ IBOutlet NSPopUpButton *aRows; IBOutlet NSPopUpButton *aColumns; IBOutlet NSPopUpButton *aRowCols;// hierarchical popup button } // +-+-+-+-+-+-+-+-+ // Declare the instance variable properties, so accessor methods are generated // +-+-+-+-+-+-+-+-+ //@property (nonatomic, retain) IBOutlet NSPopUpButton *aRowCols; //@property (nonatomic, retain) IBOutlet NSPopUpButton *aRows; //@property (nonatomic, retain) IBOutlet NSPopUpButton *aColumns; // +-+-+-+-+-+-+-+-+ // ACTION METHODS // +-+-+-+-+-+-+-+-+ - (IBAction)selectRowsPopupMenu:(id)sender; - (IBAction)selectColumnsPopupMenu:(id)sender; - (IBAction)selectRowAndColumnPopupMenu:(id) sender; // +-+-+-+-+-+-+-+-+ @end // MainView.m #import "MainView.h" static NSUInteger noOfBoxes = 3;// These created a problem when defined as iVars, static NSUInteger noOfRows = 2; // and one of the popup menu selections changed // +-+-+-+-+-+-+-+-+ // IMPLEMENTATION // +-+-+-+-+-+-+-+-+ @implementation MainView // @synthesize aRowCols; // @synthesize aRows; // @synthesize aColumns; // +-+-+-+-+-+-+-+-+ #pragma mark - #pragma mark Action Routines - Popup Menus #pragma mark - // +-+-+-+-+-+-+-+-+ - (IBAction) selectRowAndColumnPopupMenu:(id) sender { // NSMenu *projectMenu = [sender menu]; // NSLog(@"projectMenu = %@", projectMenu); // NSUInteger *menuValue = [[sender titleOfSelectedItem] intValue]; NSUInteger *menuValue = [sender indexOfSelectedItem]; NSLog(@"[4301] menuValue %d", menuValue); NSMenuItem *menuItem = [sender selectedItem]; NSLog(@"menuItem %@", menuItem); NSLog(@"hasSubMenu %d", [menuItem hasSubmenu]); NSMenu *subMenu = [menuItem submenu]; NSLog(@"submenu %@", subMenu); // NSUInteger *subMenuValue = [[subMenu titleOfSelectedItem] intValue]; // NSLog(@"[4302] subMenuValue %d", subMenuValue); } // +-+-+-+-+-+-+-+-+ - (IBAction)selectRowsPopupMenu:(id)sender { noOfRows = [[aRows titleOfSelectedItem] intValue]; NSLog(@"[4807] -(IBAction)selectRowsPopupMenu:(id)sender --> %d", noOfRows); [mainView setNeedsDisplay:YES]; // Invalidate the mainView area, so it will get redrawn } // +-+-+-+-+-+-+-+-+ - (IBAction)selectColumnsPopupMenu:(id)sender { noOfBoxes = [[aColumns titleOfSelectedItem] intValue]; NSLog(@"[4808] -(IBAction)selectColumnsPopupMenu:(id)sender --> %d", noOfBoxes); [mainView setNeedsDisplay:YES]; // Invalidate the mainView area, so it will get redrawn } // +-+-+-+-+-+-+-+-+ // +-+-+-+-+-+-+-+-+ - (void)awakeFromNib { // I don't try to set the hierMenu here, I am just accepting what I set in IB // it would be great to be able to set the (row, col) dynamically here as well
Re: NSPopupButtons work, but not in hierarchical mode, what am I missing here ?
I think I am having the same problem as : Submenus - What am I not understanding? I was hoping that someone might see what I am trying to do and perhaps offer some ideas on a work-around, the ideas I've come up with are not pretty... Thanks again, Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How do you set the text in an NSTextView?
GS, // +-+-+-+-+-+-+-+-+ // testAppDelegate.h // test // +-+-+-+-+-+-+-+-+ #import @interface testAppDelegate : NSObject { NSWindow *window; IBOutlet NSTextView *textView; } @property (assign) IBOutlet NSWindow *window; @end // +-+-+-+-+-+-+-+-+ // +-+-+-+-+-+-+-+-+ // testAppDelegate.m // test // +-+-+-+-+-+-+-+-+ #import "testAppDelegate.h" @implementation testAppDelegate @synthesize window; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Insert code here to initialize your application } -(void)awakeFromNib { NSString *myString = @"this is a string"; [textView insertText:myString]; } // +-+-+-+-+-+-+-+-+ @end I don't know if this will help at all but, as I have been learning stuff, I have been trying to document what I've learned : http://www.journey-of-flight.com/bh_xcode/how-to/0010_IB_Outlets_and_Actions/IB_Outlets_and_Actions.php Best, Bill Hernandez Plano, Texas On May 7, 2010, at 9:33 AM, G S wrote: > Hi all. I have a couple of tabs on my window, each of which has an > NSTextView. You have to declare the IBOutlet variable in the app delegate > as an NSScrollView; only by doing that can you get the outlet to show up on > the Control-drag to the widget in Interface Builder. > > So I have the outlets connected, but an attempt to call setTextValue on the > textview results in an "unrecognized selector" report. How do you set the > text in the textView? I tried getting the text container, but no dice. > > Thanks! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How do you set the text in an NSTextView?
On May 7, 2010, at 11:49 AM, Douglas Davidson wrote: > You don't want to call insertText: for this. From the documentation: "This > method is the entry point for inserting text typed by the user and is > generally not suitable for other purposes. Programmatic modification of the > text is best done by operating on the text storage directly. Because this > method pertains to the actions of the user, the text view must be editable > for the insertion to work." > > The simplest way to set the entire contents is to call setString:. More > detailed modifications are best done by operating on the text storage, which > is a subclass of NSMutableAttributedString. > > Douglas Davidson Douglas, Great reply, thank you I noticed that as I had been learning this stuff, and creating small projects, in some places I had used {getter, setter} = {string, setString} [textView setString:@"Welcome"]; NSString *myString = [textView string]; but I noticed I had used this at one point, and thought it was acceptable ? [textView insertText:myString]; Thank you so much for the great clarification ... Best, Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSPopupButtons work, but not in hierarchical mode, what am I missing here ?
Gary, This is way over my head, but I will re-read this several times, I am sure. Thanks for pointing the way. I will try to look at all the sources you mentioned. The biggest problem I've had, is that for the most part the demos that Apple provides are too advanced for where I am at in the learning process. I love this list Thank You.... Bill Hernandez Plano, Texas On May 7, 2010, at 11:50 AM, Gary L. Wade wrote: > Try a different UI approach. > > One thing to consider is using an NSBrowser if you have lots of upper-level > options and a good number of sub items and want a cascading list where the > leaf item is just a choice rather than a command. > > If you want commands but have a small number of upper-level options and a > relatively small number of sub items, consider using header-oriented menu > items and possibly set their sub items to use an indentation level. Look at > the Speech System Preference's System Voice popup button after choosing > "Show More Voices". It doesn't use indentations, but the graying and > separators shows a clear delineation. If you want the headers to be > commands in their own right, you would most likely want to use indentations, > but it's debatable for their need if they're not selectable, such as with > the System Voices. > > Of course, you may have to do things a lot harder; Apple even uses > hierarchical menu items in a popup button for the Region on the Formats > panel of the Language & Text System Preference when you turn on "Show all > regions", but that's definitely a huge list. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Good Resources ?
Everybody, I started trying to learn Cocoa, Xcode, Objective C, etc sometime around November/December 2009 timeframe, and began trying to document what I learned along the way, mostly for myself as a learning experience, but also to help others trying to do the same. I realize there are tons of demos, tutorials, etc created by people far more qualified than me, and hopefully anyone who might benefit from this effort will overlook errors in my logic, insufficient knowledge, or just plain buffoonery on my part. My new website which I started in November 2009 is located at : http://www.journey-of-flight.com I am retired so none of this is for any personal gain but merely for the reasons I stated above. I am trying to keep a list of useful resources for the benefit of all, and would like some help in identifying any that you think I might have missed. Here's the page: http://www.journey-of-flight.com/bh_xcode/common/cocoa_programming_resources.php TIA, Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
More general question related to : How do you set the text in an NSTextView?
This is a follow-up question of a more general nature related to : Re: How do you set the text in an NSTextView? On May 7, 2010, at 11:49 AM, Douglas Davidson wrote: > On May 7, 2010, at 9:41 AM, Bill Hernandez wrote: > >> [textView insertText:myString]; > > You don't want to call insertText: for this. From the documentation: "This > method is the entry point for inserting text typed by the user and is > generally not suitable for other purposes. Programmatic modification of the > text is best done by operating on the text storage directly. Because this > method pertains to the actions of the user, the text view must be editable > for the insertion to work." > > The simplest way to set the entire contents is to call setString:. More > detailed modifications are best done by operating on the text storage, which > is a subclass of NSMutableAttributedString. > > Douglas Davidson Douglas, As a general learning excercise : I was looking at NSTextView this morning to make sure I understood where I had gone wrong and make corrections in my logic, but am a little confused right now and would be grateful for any insights. When I was learning how to access the docs after watching some of the introductory videos, I noticed that rather than scan the Class, or Instance Methods for something that might do what you need, as I recall a recommended procedure was to hold down the option key and double click on the class name (in this case NSTextView) and once the help window became available, up the Tasks section. Once in the Tasks section look for a topic that might fit what you are trying to accomplish. Then if you can't find a solution, the next step would be to look at each superclass, all the way back NSObject to see if there is something that might work for your needs. So I went back to trace those steps to see where I went wrong and I noticed that if I open Tasks the only thing I see that looks like it might do what I need is "InsertingText" and when I click on that, the least scary method from a novice's point of view appears to be "– insertText:". I remembered that as I had looked through the Instance Methods earlier I couldn't find anything that would give me a clue to use setString. The funny part was that I remembered {"- string:", "- setString:"} from before, but when I saw "– insertText:" and hovered the cursor over it : -- insertText: -- Inserts aString into the receiver’s text at the insertion point if there is one, otherwise replacing the selection. -- and if I would have read a little further, I would have seen : -- - (void)insertText:(id)aString -- Parameters aString The string to insert. aString can be either an NSString object or an NSAttributedString object. Discussion The inserted text is assigned the current typing attributes. This method is the means by which text typed by the user enters an NSTextView. See the NSInputManager class and NSTextInput protocol specifications for more information. This method is the entry point for inserting text typed by the user and is generally not suitable for other purposes. Programmatic modification of the text is best done by operating on the text storage directly. Because this method pertains to the actions of the user, the text view must be editable for the insertion to work. -- After you mentioned that I should have used {"- string:", "- setString:"} and I went to the superclass NSText docs, I searched for "– string", and found that the topic for "– string" is : -- Getting the Characters -- – string My normal instinct would have never led me to look at "Getting the Characters" because that leads me to think "INDIVIDUAL Characters", not something like {"Getting the String Value", "Setting the String Value", etc}. Grant it, I should have remembered from when I was learning about NSTextView objects, but the real question for me, is how would you proceed trying to get quick help on a specific Task that you might need to accomplish, without spending an hours researching each command that you intend to use ? If I was interested in finding a method to help me solve a problem how would I best proceed (pretending we had never heard of NSTextView and this was our first encounter with it). The reason I ask insights on how to proceed, is that Cocoa is so massive that you could spend years reading before you actually wrote any code. Thanks for any help... Bill Hernandez Plano, Texas __
Re: More general question related to : How do you set the text in an NSTextView?
On May 9, 2010, at 9:46 AM, Bill Hernandez wrote: > and once the help window became available, up the Tasks section. should have been : and once the help window became available, open the Tasks section. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
TUTORIAL: Generating Unique ID Strings
I ran into an interesting thread on the Cocoa Developers discussion group, and thought I 'd try to create a small demo, to see what I could learn, and sure enough I learned a lot. There were quite a few people that participated and provided a lot of great information, I tried to quote the email messages, and give credit to the people that provided some of the code, and the insights. I hope I didn't leave any one out, if I did, it was not intentional. On my website the tutorial is listed under the following : http://www.journey-of-flight.com/index.php Cocoa - Generating Unique ID Strings or you can reach the page directly at : http://www.journey-of-flight.com/bh_xcode/how-to/0086_Unique_ID/index.php I also added a resources link at : http://www.journey-of-flight.com/bh_xcode/common/cocoa_programming_resources.php if you see any that I should add, please let me know. Hope this is useful Bill Hernandez Plano, Texas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: TUTORIAL: Generating Unique ID Strings
On May 14, 2010, at 12:05 PM, Jens Alfke wrote: > Oh, also, a comment on the site design: why do you present source code in the > form of screenshots of Xcode windows? This makes it impossible for a user to > copy the text easily, for a blind user to read it at all, or for a search > engine to index it. It also consumes orders of more bandwidth (for you and > the viewer) than just the plain text would. > > —Jens > Oh, also, a comment on the site design: why do you present source code in the > form of screenshots of Xcode windows? ( 1 ) I frequently make circles, boxes, and arrows around some of the code images. ( 2 ) All the colors are accentuated, and the user sees exactly what I see. ( 3 ) In order to show the source code (exactly as the screen captures show) using HTML would require so much more work for me, that I would just quit doing these little tutorials altogether. I know that most people on these forums know a whole lot more than me, and that's OK, but most most of them don't have the time to create tutorials, so hopefully there will be some people that can benefit from the incredible amount of time it takes to figure out some of this stuff. This Cocoa stuff is geared for the beginner like myself, obviously not for the experts on this forum. > This makes it impossible for a user to copy the text easily, for a blind user > to read it at all, or for a search engine to index it. I agree with what you are saying, but I include the xcode projects for the user to download. This way they can make sure that the projects work as expected. I have spent so much time reading text tutorials, that after I copy and paste, etc. will not run at all, and when you try to write to the author, they do not respond. > It also consumes orders of more bandwidth (for you and the viewer) than just > the plain text would. Because I am not a good writer, I prefer to have more images with minimal text. That is my preferred style. On my home page at http://www.journey-of-flight.com , I have the following at the top of the page : -- NOTE : I got some feedback from someone with a low speed connection : "If you don't have a high speed connection, you may want to avoid my site. All the tutorials have a lot of images which might load slow otherwise. I tend to forget that I am extremely fortunate to have (20/5) MBit Business FIOS service at home, so for me they load lightning quick, but please be aware of the loading time if you do have a slow connection." If you have suggestions, or comments, that's fine, but try to keep them polite... -- We all have different styles, and it is tough to please everybody. A couple of times I thought I would close down the website, or at least remove the Cocoa stuff, because I would post the tutorials on some of the boards and ask for feedback, and I can count on one hand the few times anyone said anything, positive or negative. I got a really nasty note from some guy that hated the font I used. Go figure ? Then yesterday out of the clear blue sky, I got the following, and I was floored that someone appreciated the work : -- From: scott.m.ba...@mchsi.com Subject:Saw some of your work on your website... (and it rocks) Date: May 13, 2010 12:58:14 PM CDT To: Bill Hernandez Hey Bill, I just wanted to reach out and thank you for all of your absolutely fantastic Xcode tutorials with relation to Obj-C and Interface Builder. I had been a long time AppleScript Studio user (then had to move over to Windows programming for a few years) and I recently had to come back over to the Mac to work on a project. Of course upon arrival, I was shocked to see ASS had been replaced with AppleScriptObjC. Thus began my (rather short) journey into learning it and after about 90 minutes of quite a few "why wouldn't I just use Obj-C but I don't know it" fears, I came across your site and all my doubts about being able to use it went right away. I am a pretty experienced C# guy and I was actually pleasantly surprised to see how easy it was to make the connection between the two. Your IB tutorials helped fill the gaps (amazed at how easy it really is) and I am on my way. I'll also be picking up some of your recommended books but overall I have you to thank for really connecting the dots and pointing my in the right direction. So thanks again Bill. Truly, truly appreciate your site!! Scott -- Anyway Jens, thanks for the feedback. I'll think about what you said... Best Regards, Bill Hernandez Plano, Texas http://www.journey-of-flight.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Re: TUTORIAL: Generating Unique ID Strings
On May 14, 2010, at 1:39 PM, Daniel Grace wrote: > There's something called Gist. It's largely part of github, but you > don't have to use github to use it. There are other choices, but I do > use github, so Gist is the one that I'm aware of. > > http://gist.github.com/ > > Not saying that you have to use it, but it's always good to be aware > of all of your choices. > > Daniel > http://www.doomstick.com Daniel, It looks pretty nice, I will have to spend some time trying to see how I can use it. I had been using SubVersion via Apache on my OS X Server, and finally gave up and I am using something I wrote temporarily. I have heard good things about GIT, and really need to see how that would work. More importantly how might be a good way to setup my workflow to take advantage of GIT. Thanks a lot for taking the time to help... Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: TUTORIAL: Generating Unique ID Strings
On May 14, 2010, at 2:14 PM, Jens Alfke wrote: > You don't have to use any particular version control system to use gists. > It's just a service provided by GitHub. All it does is let you paste in some > source code to create a web page from it, with syntax highlighting and line > numbers and everything. Then you can link to it or even inline it into your > page. I tried a page on, but it didn't do the color highlighting, I need to see if there are some options that I need to set, etc. https://gist.github.com/53cc09788370d2acd21b https://gist.github.com/2c096e1576c128e12800 I dont have a problem generating any kind of html, or php, I prefer colored syntax similar to my screen captures. I really like the way Cocoa does the Midnight Color Theme. >> I got a really nasty note from some guy that hated the font I used. Go >> figure ? > > I wasn't going to say anything, but since you're already complaining about > people not taking your site seriously: I wasn't complaining. When I started learning Cocoa I decided I would try to document what I learned from a beginner's perspective, in the hopes that it would help somebody else. After I had posted a few tutorials I began to notice that several hundred people had at least looked at the messages I posted on the different forums that kept counters, and the AwStats on my hosting service showed that I was getting 30,000 hits a month on my website, I was floored, I had no clue that anybody would even look at my stuff. It made me very happy that maybe some of this stuff was helping others. Anytime I posted the messages I always asked if possible for some feedback in order to help me make the tutorials more useful, but nobody ever said anything. I understand it takes effort to sit down and give feedback. Since I started doing this I have been more conscious to give others feedback on their efforts. I got three or four nice notes and one ugly one, but no real feedback As for the font, I happen to like it better that arial, helvetica, lucida, etc., but I will try to find another font that might be an alternative. > Comic Sans is a poor choice on several levels. It has poor legibility, its > silly appearance conflicts with the serious nature of your site, and a lot of > people (especially designers) hate it with a passion because it's both poorly > designed and incredibly overused by people trying to be cute. So it conveys > sort of the same effect as if you were using animated GIFs of sparkly > rainbows in the background of your site :) Thanks for the feedback ! Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
SETUP : Regular Expressions - Easy Setup for RegexKitLite
I've been using RegexKitLite for regular expressions for a little while, and the other day when I went to add it to another project, I had forgotten about the project setup. I was getting debugging errors, and finally remembered that I had to add -licucore to the other linker flags. I decided to make a few screen captures (10) that make it really easy to see the small change that needs to be made to each project that uses regular expressions. It is really simple and makes coding much easier than by using some of the Cocoa methods for similar tasks. It is listed under : RegexKitLite Quick Setup http://www.journey-of-flight.com/bh_xcode/common/regex_kit_lite/regex_kit_lite_install.php I also updated : Cocoa, Xcode, Objective C - Useful Resources... http://www.journey-of-flight.com/bh_xcode/common/cocoa_programming_resources.php I added a couple of really neat tools that make life much easier. Hope some of this is helpful. Best Regards, Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: SETUP : Regular Expressions - Easy Setup for RegexKitLite
On May 15, 2010, at 7:02 PM, Jens Alfke wrote: > FYI, you don’t have to edit the linker flags anymore to do this. In Xcode > 3.1+ you can open the target inspector, choose the General tab, and click the > + button at the bottom left to pop up a list of available libraries. Then > choose “libicucore.dylib”. Jens, Thanks a million, I am almost sensing that you are becoming my mentor. It's nice having someone out there trying to keep you from committing some massive buffoonery, thank you. I mean well, but my knowledge and experience just aren't there... I added your comments to the notes on the page, and took a couple of additional screen captures that shows what you shared. Correction made : http://www.journey-of-flight.com/bh_xcode/common/regex_kit_lite/regex_kit_lite_install.php Under : Some Feedback Best Regards, Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
TIPS : Using Add2Project to organize your projects more effectively.
http://www.journey-of-flight.com/index.php Cocoa - Using Add to Project to Organize Your Projects More Effectively. Use Xcode Add2Project to automatically create a folder hierarchy that matches the Groups and Files virtual hierarchy... or you can reach the page directly at : http://www.journey-of-flight.com/bh_xcode/how-to/0016_Add2Project/index.php I also added quite a few items to the resources link at : http://www.journey-of-flight.com/bh_xcode/common/cocoa_programming_resources.php if you see any that I should add, please let me know. Hope this is useful Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Regarding MVC design pattern
On May 17, 2010, at 12:33 AM, Quincey Morris wrote: > Your Model is being initialized because the NIB file that contains it is > being loaded. The gory details of what happens can be found here: > > > http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html Quincey, Thanks for the reference, I pulled it up, clicked on PDF, and it is printing as I type this thank you note... When I clicked on PDF the whole document pulls up : http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/LoadingResources/LoadingResources.pdf Best Regards, Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
TIPS : Printing Apple Docs Selectively
This is something I found useful, so I documented it, and thought I'd share it... Listed under : Cocoa - Printing Documentation Cocoa - Tips for printing selected portions of the documentation... At : http://www.journey-of-flight.com/index.php or you can reach the page directly at : http://www.journey-of-flight.com/bh_xcode/how-to/0005_Documentation/Documentation.php I also added a few more items to the resources link at : http://www.journey-of-flight.com/bh_xcode/common/cocoa_programming_resources.php if you see any that I should add, please let me know. Hope this is useful Bill Hernandez Plano, Texas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Blog post announcements
On May 18, 2010, at 1:09 AM, Scott Anguish wrote: > Hi Bill > > I moderate the cocoa-dev list. I’m hoping you could do be a favor. Can you > pace yourself a bit on announcing your blog posts? Perhaps collect a few and > post them once a week? > > I’ve had a few people poke me about it. I don’t want to discourage, just try > and cut down traffic. > > Much appreciated. > > Scott I am sorry Scott, in my exuberance to share what I've been learning, I din't realize that I was creating a problem, or that I was offending anyone. I am so sorry, I won't be making any further posts. Thank You for making me aware of the problem. Sincerely, Bill Hernandez Plano, Texas___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com