Questions tagged [nsbundle]

An NSBundle object represents a location in the file system that groups code and resources that can be used in a program. NSBundle objects locate program resources, dynamically load and unload executable code, and assist in localization. You build a bundle in Xcode using one of these project types: Application, Framework, plug-ins.

An NSBundle object represents a location in the file system that groups code and resources that can be used in a program. NSBundle objects locate program resources, dynamically load and unload executable code, and assist in localization. You build a bundle in Xcode using one of these project types: Application, Framework, plug-ins.

568 questions
6
votes
1 answer

NSBundle mainBundle pathForResource (maybe not the same problem)

Problem : [NSBundle mainBundle] pathForResource returns null (0x0) I read a lot of posts on this topic, here is what I found: Make sure the file you are trying to get a path to, is in the project. To check, look in the project file list for the…
nycynik
  • 7,371
  • 8
  • 62
  • 87
6
votes
3 answers

Loading resources from another bundle

If I have a bundle that contains a class and some resources used by that class. If I load the class from the bundle how should I load the resources(that are in the bundle where I loaded the class from) in that class? Let's say I want to load an…
thealch3m1st
  • 282
  • 1
  • 4
  • 11
6
votes
5 answers

arrayWithContentsOfFile can't read plist file

i have a plist with an array that contain 2 strings see image : http://imageshack.us/photo/my-images/263/myplist.png/ and in my viewDidLoad i add this : NSString *file = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"]; NSArray…
funnyCoder
  • 787
  • 2
  • 10
  • 30
6
votes
2 answers

NSInternalInconsistencyException Could not load nib ind bundle

I am developing an application for the iPad. The application has following details: Base SDK: 4.2 Deployment Target: 3.2 The application is a game application and it has got 10 rounds. In each round I am loading 6 controllers and after the…
GameLoading
  • 6,688
  • 2
  • 33
  • 57
6
votes
1 answer

How can I access /Library/Caches from a bundle?

My app downloads images from a server. I'd like to save those images to the Caches folder and then access them with UIImage(named:... for in-memory caching. Will UIImage(named: "fileURL", in: NSBundle.mainBundle, compatibleWith: nil) find the Caches…
Hex Bob-omb
  • 314
  • 4
  • 10
6
votes
3 answers

Include copy of JVM in app bundle

I have an OS X objective-c app which programmatically invokes the Java command to run a Java program. If I'm correct, Java is no longer installed by default on OS X. I want to ship my app and not force users to download Java before they can use the…
edwardmp
  • 6,339
  • 5
  • 50
  • 77
6
votes
1 answer

OCMock doesn't stub NSBundle method

I'm using since recently OCMock for my unit testing. I need to stub the objectForInfoDictionaryKey: method from NSBundle. I've done the following : self.bundleMock = OCMClassMock([NSBundle class]); OCMStub([self.bundleMock…
Loadex
  • 1,502
  • 1
  • 12
  • 25
6
votes
1 answer

Including image assets when releasing a Cocoapod

I have made a custom Cocoa control and want to release it and write a podspec. My control contains one image. How can I package this image so that when others install my pod, my code can find the image? At the moment the image is included in the…
Daniel Farrell
  • 9,316
  • 8
  • 39
  • 62
6
votes
2 answers

How can I include a txt file in an Xcode project?

I added a file "IntegerArray.txt" as follows, first I went to File -> Add file to "project name", I selected my file and it was copied into the root folder of my project, the same one that contains the .xcodeproj file. Then I clicked on my project's…
11Kilobytes
  • 451
  • 1
  • 6
  • 15
6
votes
3 answers

How can I load an image from Assets.car (compiled version of xcassets) within an NSBundle? (without using CocoaPods)

We're getting these kind of error messages: Could not load the "iconStatus" image referenced from a nib in the bundle with identifier "com.company.OurResourceBundle". Basically, we put a bunch of images in the xcassets folder ( which works for…
Tom Fishman
  • 1,716
  • 6
  • 22
  • 36
6
votes
3 answers

principal class of NSBundle

Plz help me to understand what is principalClass used for?what is the syntax of it. i understand tat it is in NSBundle Class,but can we create it for any bundles of is it specific only for laodable bundles? plz help me to know the concept of…
suse
  • 10,503
  • 23
  • 79
  • 113
6
votes
3 answers

How to add/open a bundle file in a test target

I have a static library that gets linked to by an application. The library code opens a file that is in bundle that is in the application bundle, the opening is done as: NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"Config"…
Gruntcakes
  • 37,738
  • 44
  • 184
  • 378
5
votes
1 answer

Add and read a json file in the iPhone app

I have created a simple Xcode 4.2 project with a empty view controller. I added a json file to this project (i not had a resouces folder/group and so i have create these resouces folder and group). So, in my iphone simulator i can read this json…
Safari
  • 11,437
  • 24
  • 91
  • 191
5
votes
2 answers

Write in Main Bundle directory. Is it allowed?

I was pretty sure that writing in the main Bundle isn't possible in iOS ... for example an operation like : NSString *path = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"]; .....something [xmlData writeToFile:path…
MatterGoal
  • 16,038
  • 19
  • 109
  • 186
5
votes
1 answer

NSBundle folder not found on device, but works in simulator

I'm having a really weird problem with the iPad app I'm writing. On startup I want to copy a folder containing a few other folders (that are empty) from the application bundle to the Documents directory. The folder to be copied, called 'flds' (all…
hsdev
  • 507
  • 3
  • 12