NSBundle pathForResource is NULL

So here’s the solution for this problem after I got the source: I didn’t really pay attention to the posted screenshot, but the target is of type “Command-line Tool“… and since those don’t have a bundle [NSBundle mainBundle] of course returns nil. It’s pretty misleading that Xcode doesn’t complain that it can’t execute the “Copy … Read more

core data in a static library for the iPhone

Sascha’s answer got me on the right track. Merging a compiled .mom file from a static library into the .mom file from a host project was relatively simple. Here’s a trivial example: Create a new XCode Static Library project called MyStaticLibrary Create an .xcdatamodel file in MyStaticLibrary called MyStaticLibraryModels.xcdatamodel, add some Entitys, then generate the … Read more

Access Asset Catalog pathForResource

Same problem, but I don’t think we could access it via pathForResource:, except below: UIImage* image = [UIImage imageNamed:@”name-in-asset-catalog”]; It has been clearly documented: Each set in an asset catalog has a name. You can use that name to programmatically load any individual image contained in the set. To load an image, call the UIImage:imageNamed: … Read more

Write a file on iOS

May be this is useful to you. //Method writes a string to a text file -(void) writeToTextFile{ //get the documents directory: NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; //make a file name to write the data to using the documents directory: NSString *fileName = [NSString stringWithFormat:@”%@/textfile.txt”, documentsDirectory]; //create content – … Read more

tech