Set UIButton title UILabel font size programmatically
button.titleLabel.font = [UIFont systemFontOfSize:size]; should help
button.titleLabel.font = [UIFont systemFontOfSize:size]; should help
First of all, floating point values are not “random” in their behavior. Exact comparison can and does make sense in plenty of real-world usages. But if you’re going to use floating point you need to be aware of how it works. Erring on the side of assuming floating point works like real numbers will get … Read more
I use [NSException raise:format:] as follows: [NSException raise:@”Invalid foo value” format:@”foo of %d is invalid”, foo];
I commit my Pods directory. I don’t agree that the Pods directory is a build artefact. In fact I’d say it most definitely isn’t. It’s part of your application source: it won’t build without it! It’s easier to think of CocoaPods as a developer tool rather than a build tool. It doesn’t build your project, … Read more
Here are some useful macros around NSLog I use a lot: #ifdef DEBUG # define DLog(fmt, …) NSLog((@”%s [Line %d] ” fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) #else # define DLog(…) #endif // ALog always displays output regardless of the DEBUG setting #define ALog(fmt, …) NSLog((@”%s [Line %d] ” fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) The DLog macro is … Read more
In Xcode 4.x press ⌥⌘R (or click Menubar > Product > Scheme > Edit Scheme) select the “Diagnostics” tab and click “Enable Zombie Objects”: This turns released objects into NSZombie instances that print console warnings when used again. This is a debugging aid that increases memory use (no object is really released) but improves error … Read more
Like most of the other answers have said, instance methods use an instance of a class, whereas a class method can be used with just the class name. In Objective-C they are defined thusly: @interface MyClass : NSObject + (void)aClassMethod; – (void)anInstanceMethod; @end They could then be used like so: [MyClass aClassMethod]; MyClass *object = … Read more
objectForKey will return nil if a key doesn’t exist.
The generally-preferred code for 10.5+/iOS. for (id object in array) { // do something with object } This construct is used to enumerate objects in a collection which conforms to the NSFastEnumeration protocol. This approach has a speed advantage because it stores pointers to several objects (obtained via a single method call) in a buffer … Read more
The code for percent sign in NSString format is %%. This is also true for NSLog() and printf() formats.