uikit

MyApp_Prefix.pch warning:

The compiler complains about this, after I activated all kind of warnings: #ifdef __OBJC__ #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #endif warning: #import is a GCC extension What does that mean? ...

warning: -Wuninitialized is not supported without -O

The compiler complains about this, after I activated all kind of warnings: For MyApp_Prefix.pch the compiler says: warning: -Wuninitialized is not supported without -O What does that mean? ...

warning: passing argument 1 of 'numberWithBool:' with different width due to prototype

The compiler complains about this, after I activated all kind of warnings: I create an NSNumber like this: NSNumber *num = [NSNumber numberWithBool:YES]; warning: passing argument 1 of 'numberWithBool:' with different width due to prototype it complains about the value I provided. What's wrong with "YES"? What does that mean? ...

warning: passing argument 3 of 'objc_setProperty' as signed due to prototype

The compiler complains about this, after I activated all kind of warnings: I have an app delegate like this: #import <UIKit/UIKit.h> @class MyViewController; @interface TestAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; MyViewController *myViewController; } @property (nonatomic, retain) IBOutlet UIWindow ...

Does it matter to have an class without members?

I have a class with only class methods (utility stuff), so my interface is like: @interface MyUtils : NSObject { } Xcode doesn't like it and says: warning: struct has no named members So I have to create a nonsense instance variable? My code works fine, though... I just activated every kind of warning for the compiler. ...

Easy way to print current stack trace of an app?

Xcode / objective c does not really print a useful stack trace. My app crashes somewhere, and the damn thing gives me only numbers like 45353453, 34524323, 6745345353, 457634524234. Not useful at all. So I want to make a NSLog(); on the beginning of EVERY method I have in my entire app. But maybe there's a simpler way to just find out t...

How to get the name or signature of the current method into an NSString?

Example: I have a method -myFooBarMethod:withFoo:bar:moreFoo: and inside the implementation of that method I want to dynamically get the name of it, like @"-myFooBarMethod:withFoo:bar:moreFoo: into an NSString. No hard-typing of the method signature. I feel that this has to do something with selectors. How could I get the name of the c...

How to get the name of a class of a method as NSString?

I need the name of the class that owns a method, as NSString. Example: There's a -fooBar method inside a SomeClass, and that -fooBar method runs some code. This code must print out what class "owns" it, I mean: What class that method belongs to. So I can't hard-type the class name in a NSString because I need that for debugging purposes,...

What are assertions or NSAssert good for in practise?

I wonder if it's a good habit to use NSAssert all over the place? What would be the benefit of doing that? In which situations is it a good idea to use it? ...

How to get rid of all this garbage in NSLog?

When I use NSLog(@"fooBar") it prints out a lot of stuff I don't want: 2009-09-03 13:46:34.531 MyApp[3703:20b] fooBar Is there a way to print something to the console without this big prefix? I want to draw a table and some other things in the console so that space is crucial... ...

How to check in an NSAssert of an variable is (null) ?

the console prints me (null) for an variable that should not be, so I want to put an assert there just for fun: NSAssert(myVar, @"myVar was (null)!"); what's the trick here? this (null) thing doesn't seem to be "nil", right? How can I check for it? I want to assume that the var is set properly and not nil, not null. ...

What's the point of NSAssert, actually?

I have to ask this, because: The only thing I recognize is, that if the assertion fails, the app crashes. Is that the reason why to use NSAssert? Or what else is the benefit of it? And is it right to put an NSAssert just above any assumption I make in code, like a function that should never receive a -1 as param but may a -0.9 or -1.1? ...

How to pull up a UIKeyboard without a UITextField or UITextView?

I'm currently developing an OpenGL ES game for the iPhone and iPod touch. I was wondering how I can easily pull up the UIKeyboard? Is there an official, documented possibility to pull up a UIKeyboard without using a UITextField of UITextView? ...

Do I have to copy and autorelease this string?

When stepping with the debugger through this, dfString is invalid after [df release] - (NSString*)dateFormatStringWithLocale:(NSLocale*)locale { NSDateFormatter* df = [[NSDateFormatter alloc] init]; [df setDateStyle:NSDateFormatterShortStyle]; [df setTimeStyle:NSDateFormatterShortStyle]; [df setLocale:locale]; NSStri...

How to change a date by changing AM / PM hours period in 12h format?

In the docs, Apple gives an example on how to add some hours and minutes to an existing date: NSDate *today = [NSDate date]; NSDateComponents *offsetComponents = [[NSDateComponents alloc] init]; [offsetComponents setHour:1]; [offsetComponents setMinutes:30]; NSDate *endOfWorldWar3 = [gregorian dateByAddingComponents:comps toDate:today o...

Secure way to figure out if a given date format has an 12h or 24h format?

I know this sucks. Date stuff sucks hard. But: Imagine a date format like "dd-MM-yyyy h:mm" how would you tell for sure what time mode that is? AM / PM or 24 hour? I'd say: If there is no "a" in the date format, then that's no AM / PM stuff and therefore it's nice 24h stuff. What do you think? ...

How to find performance bottlenecks in an iPhone app?

I feel my app has bad performance, and want to figure out which parts in code are evil. Is there a good tutorial somewhere on how to find these? ...

How can I make an animated GIF with the iPhone SDK?

Animated GIFs are awesome. Does anyone know how to create and save them using the technologies available to the iPhone? ...

How to bind the symbols of an app on the device to Shark?

The docs say: Important: Shark cannot capture symbol information on the iPhone itself, so “raw” sessions recorded from an iPhone will appear in Shark labeled only based on sample address ranges. This can make it very difficult to understand the results that Shark returns. Instead, you must tell Shark to recover symbol...

NSString text pixel length

How to know how much pixels my text is taking in a UILabel ? I want to insert a small picture in between text. Can be usefull to adjust my label width. ...