Tag: cocoa touch

Convert first number in an NSString into an Integer?

I have an NSString like so: @”200hello” or @”0 something” What I would like to be able to do is take the first occuring number in the NSString and convert it into an int. So that @”200hello” would become int = 200. and @”0 something” would become int = 0.

How do I detect a touch on a UIBezierPath and move a ball along that?

How do I move a ball along a specific UiBezierPath? Is that possible? I’ve tried everything including doing a hit test using -(BOOL)containsPoint:(CGPoint)point onPath:(UIBezierPath*)path inFillArea:(BOOL)inFill How do I detect a touch along a path?

iOS persistent storage strategy

I’m developing an app which will save data to the local file system. The data that will be saved will be mostly NSString and NSDate. The data will not be saved that often, perhaps new data will be entered 10 times at a typical usage. The data should also of course be retrievable (CRUD) How […]

Recommended way to declare delegate properties with ARC

I used to declare all delegate properties as @property (assign) id<FooDelegate> delegate; I was under the impression that all assign properties should now be weak pointers, is this correct? If I try to declare as: @property (weak) id<FooDelegate> delegate; I get an error while trying to @synthesize (autogenerated weak properties are not supported). What’s the […]

setStatusBarOrientation:animated: not working in iOS 6

I’ve used this code to force an orientation change back to portrait when the user is finished watching the video (it allows viewing in landscape mode), before popping the video view controller off the navigation controller: //set statusbar to the desired rotation position [[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO]; //present/dismiss viewcontroller in order to activate rotating. UIViewController […]

Prevent iCloud sync of data (using .nosync?)

EDIT: So far, the best I’ve been able to come up with is a pop-up to ask the user to disable iCloud sync, along with moving all the data to the Documents directory so it won’t get wiped: In iOS5, is it possible to detect if a user has an app set to back up? […]

NSString @property, using copy instead of retain

I’m looking over Apple’s sample application EditableDetailView, and noticed that in one of their controllers, they’re setting an instance of NSString property with (nonatomic, copy). When would one use copy instead of retain? Is this so they can make a unique copy without affecting the existing data?

Reporting incorrect bounds in landscape Mode

I am having an issue with Landscape mode in my iPad application. I created a very small new project to show my issue I set UIInterfaceOrientation in the pList to UIInterfaceOrientationLandscapeRight In app delegate – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self.window makeKeyAndVisible]; MyController *myController = [[MyController alloc] init]; [self.window addSubview:myController.view]; return YES; } In MyController […]

How to display an image on a MKOverlayView?

UPDATE: Images who are projected on the MKMapView using a MKOverlayView use the Mercator projection, while the image that I use as input data uses a WGS84 projection. Is there a way to convert the input image, to the right projection WGS84 -> Mercator, without tiling the image up and can it done on the […]

How can I make deleteRowsAtIndexPaths: work with GenericTableViewController?

I’m using Matt Gallagher’s GenericTableViewController idea for controlling my UITableViews. My datasource is a NSFetchedResultsController. http://cocoawithlove.com/2008/12/heterogeneous-cells-in.html Everything is working fine, until I try to delete a cell. I have the following code in my View Controller: – (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { // Delete the managed object. NSManagedObjectContext *context […]