What is NSBundle and mainBundle in Objective-C?

A bundle is a structure used for packaging software on Mac OS X. Applications, frameworks and plug-ins are all different kinds of bundles. Bundles may contain executable code, resources, header files and other stuff (including other bundles) if you so wish. Bundles are implemented as directory trees with a defined structure. Applications, frameworks and plug-ins … Read more

How to use Core Data’s ManagedObjectModel inside a framework?

I’m a bit late for flohei’s issue, but hopefully this helps anybody else who wanders by. It is possible to get this to work without having to perform script-fu to copy resources around! By default Apple’s Core Data template gives you something like this: lazy var managedObjectModel: NSManagedObjectModel = { let modelURL = NSBundle.mainBundle().URLForResource(“MyCoreDataModel”, withExtension: … Read more

How to get bundle for a struct?

The best solution here depends on what you need a bundle for. Is it to look up resources that exist only in a specific app, framework, or extension bundle that’s known to be loaded when the code you’re writing runs? In that case you might want to use init(identifier:) instead of dynamically looking up the … Read more

OCUnit & NSBundle

Found only one solution for this problem. When I build my unit-tests, the main bundle’s path is not equal to my project’s bundle (created .app file). Moreover, it’s not equal to LogicTests bundle (created LogicTests.octest file). Main bundle for unit-tests is something like /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk/Developer/usr/bin. And that’s why program can’t find necessary resources. And the final … Read more

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

Get file path and URL for file in temp directory

NSTemporaryDirectory() provides a full path to the temporary directory. Instead of using your mainBundle have you tried NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@”temp.pdf”]; If you need a URL instead, do this: NSURL *furl = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@”temp.pdf”]];

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)