cocoa-touch

Force cancel a touch iphone

Hi, I have 4-5 uibuttons(also can use uiview instead of button) side by side next to each other. When user moves touch from one button to other(outside of self view), i want to cancel this touch and start touch for the next button(view). How to achieve this functionality? I used uiview instead of buttons kept it next to each other, h...

Can I encode a subclass of NSManagedObject?

This is for an iPhone App, but I don't think that really matters. I need to send a custom object (which is managed by Core Data) over bluetooth using the iPhone's GameKit. Normally, I would just use an NSKeyedArchiver to package up the object as a data object and ship it over the line, then unarchive the object and I'm done. Of course, I...

What does that mean? "mi_cmd_stack_list_frames: Not enough frames in stack."

Debugger is telling me this, when I run my app on device: Program received signal: “EXC_BAD_ACCESS”. mi_cmd_stack_list_frames: Not enough frames in stack. mi_cmd_stack_list_frames: Not enough frames in stack. I don't get information about where in code that happens. That's all I get. Any idea what that could mean? The app crashes af...

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 ...

How to switch to next view when button is pressed iPhone?

Hello, here is a iPhone programming beginner's question: How do I get to another view by pressing a button in my main view? I have the following function which is executed when I press a button, and debugging it, he passes there, but my "Warning" view does not show up: -(IBAction) showWarningView:(id)sender { if(self.showWarning ...

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. ...

UINavigationBar and UINavigationItem but no title

I've got a UITabController. One of the tabs is a UINavigationController. Pushing and popping the navigation stack works just fine. Every UIViewController has his own NIB with just the UIView hooked up. But unfortunately I only get a title displayed for the root navigation controller! Usually when creating a UIViewController in a NIB you...

IPhone - NSKeyedUnarchiver memory leak

I am using NSKeyedUnarchiver unarchiveObjectWithFile: to read in application data. When running with Leaks in Instruments, I am told that the following produces a leak: { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; ...

UITextView detecting text using RegEx

I have a UITextView where users can type text. I want to parse HTML Links (Domains with or without http://) and Phone Numbers from the users after they click on the button. I know I can set the editable property of UITextView to NO to automatically parse links but I don't have the option to make it editable=NO and I want to parse the Li...

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,...

How to create a macro with multiple lines of code?

I want to make a macro which will inject some code, like: if (foo) { [Bar fooBar]; } and then, where ever I need that, I put FOOBAR in the code. Not sure, but at compile time then the compiler replaces this with the actual code like in the example above. Maybe there's something different than a macro I could use for this? ...

Using iPhone OS 3.0 features if available, and 2.1 features if not, in one executable

Hey guys, I've seen apps on the iPhone that if running on 3.0 will use 3.0 features/APIs such as the in-app email composer, and if running on 2.x not using those features, and exiting the app to launch Mail instead. How is this done? My initial thoughts were to use #ifdef __IPHONE_3_0 but that will only work if I actually build the...

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... ...

Get New Co-Ordinate based on degrees and distance

I have a coordinate from Core Location and want to calculate the co-ordinate given a bearing and a distance, say in km. I think this is the formula from here. http://www.movable-type.co.uk/scripts/latlong.html Formula: lat2 = asin(sin(lat1)cos(d/R) + cos(lat1)sin(d/R)cos(θ)) lon2 = lon1 + atan2(sin(θ)sin(d/R)cos(lat1), ...