Learning The Swizzle & Obj-C Runtime @ Evernote – CocoaCoder.org (Austin, TX) – Meetup
The April 19th meeting is being hosted by Evernote. To add to the fun, some of their engineers will present on such topics as method swizzling, just to name one. If you’ve never done swizzling, it’s a big RPG, so be careful how you use it. JC will walk us through that. And more.
Evernote is the latest major iOS house to locate in Austin. So if you’ve thought of making the big jump into full-time iOS work, this might be a good chance.
If one goes to the NSString documentation, one quickly realizes that there is a very nice convenience method,
+ (id)stringWithString:(NSString *)aString
The string from which to copy characters. This value must not be nil.
Raises an NSInvalidArgumentException if aString is nil.
A string created by copying the characters from aString.
One would be forgiven for not noticing that little note that is supposed to catch your attention by having the title, Important. And it is important. Because, let’s say that you are trying to tell your iOS user how much an app feature upgrade cost,
NSString *titleString1 = [NSString stringWithString:@"Upgrade Flush'em for "];
NSString *titleString2 = [NSString stringWithString:[PFIAPManager sharedManager].upgradePrice];
NSString *titleString3 = [titleString1 stringByAppendingString:titleString2];
NSString *titleMessage = [titleString3 stringByAppendingString:@"?"];
Now let’s say that your intrepid customer doesn’t have a network connection. Yes, you can go through the mental exercise of asking why in the world a user would try to upgrade a mobile app without a network connection, but trust me, it will happen. And you as a responsible programmer must catch that error and handle it well for the customer. And how would you do that?
NSString *titleString2 = nil;
NSString *upgradePriceStr = [PFIAPManager sharedManager].upgradePrice;
titleString2 = [NSString stringWithString:upgradePriceStr];