nsbundle

How do I get an NSArray of filenames of all files in a given directory in my app?

What I want to do seems simple enough: Get an array of filenames in a given "directory" on my app. But the more I play around with NSFileManager and NSBundle I find myself getting more lost...I just want to get the filenames of the files organized in a specific directory in my iPhone Xcode project...For example: The directory in question...

iPhone : Get the file path which is within subfolder of Resourse folder

hi all, i am new to iphone programming. i want to read the content of text file which is located in subfolder of Resourse folder Resourse Folder Structure is following Resourse Folder1---->Data.txt Folder2---->Data.txt Folder3--->Folder1----->Data.txt There are multiple file named "Data.txt". so how can i access each folder file. i...

NSBundle, plist and other resources in an Obj-c Static Library

I've created a static library in Xcode, which I am able to successfully use in other projects. However, with resources like plists, I find I must include any plists referenced in my library in the main project where the project is used. In my static library project, I have my plist included in the "Copy Bundle Resources" phase of the ta...

Cocoa - problem with this code using NSBundle

It was suggested that I use this line of code to call an image from my resources folder/project bundle. I also see it being used exactly like this on many different website tutorials. NSBundle *mb=[NSBundle mainBundle]; NSString *fp=[mb pathForResource:@"topimage" ofType:@"PNG"]; NSImage *image=[NSImage initWithContentsOfFile:fp]; ...

core data in a static library for the iPhone

I've built a static library that makes heavy use of the Core Data framework. I can successfully use the library in my external project, but ONLY if I include the .xcdatamodel file in the main project. That is less than ideal, since the point of the library was to hide implementation details to the maximum possible. In a separate questio...

Problem getting path to .plist using [[NSBundle mainBundle] pathForResource

I'm an Objective C noob, and I don't know enough to explain the following problem. This code works: NSString *plistPath = @"/Users/andrewf/MyApp/Resources/Plates.plist"; dicPlates = [[NSDictionary alloc] initWithContentsOfFile:plistPath]; My dictionary object is loaded with values as expected. This code does not work: NSString *pli...

Why can't code inside unit tests find bundle resources?

Some code I am unit testing needs to load a resource file. It contains the following line: NSString *path = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"txt"]; In the app it runs just fine, but when run by the unit testing framework pathForResource: returns nil, meaning it could not locate foo.txt. I've made sure that foo.t...

Working with paths from [[NSBundle mainBundle] resourcePath]

I'm sure it's a very basic problem, but I'm having trouble finding anything about it. Say I've got my app in a folder, in some more folders, like this: MainFolder > SecondaryFolder > AppBundle.app > all the stuff Then, what I want to do is access a file that is in the "MainFolder". I know I can get the path of the AppBundle by using...

principal class of NSBundle...

hello, 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 principalClass. Thanking You. ...

How can you determine if a file exists within the app bundle?

Sorry, dumb question number 2 today. Is it possible to determine if a file is contained within the App Bundle? I can access files no problem, i.e., NSString *pathAndFileName = [[NSBundle mainBundle] pathForResource:fileName ofType:@"plist"]; But can't figure out how to check if the file exists there in the first place. Regards Dav...

how to load a class in Objective-C

Hello, How to load a class in Objective-C for iPhone application? I know tat Bundling concept is in MAC , but for iPhone can i use the same bundle concept to load a class? ...

warning on nsbundle bundlepath

hi. i want to get the executable path of my bundle. (i want to get the path so i can load images in a NSImageView) i got this. NSString * _Ruta_APP = [[NSString alloc] init]; _Ruta_APP = [[NSBundle mainBundle] bundlePath]; but the compiler says /ControlAPP.m:33:0 /ControlAPP.m:33: warning: local declaration of '_Ruta_APP' hides ...

iPhone: Calling [NSBundle mainbundle] Crashes on the Device But not Simulator

Basically the problem is exactly what the title says. My app works smoothly on the simulator, with no crashes whatsoever. In fact, the previous version is on the app store. I made minor changes here and there and suddenly it started to crash in a very odd place. I use [NSBundle mainBundle] resourcepath] in various places in the code to...

Confused by behaviour of NSBundle

Hi, I've a plist file that sits in a directory called Templates of my .app directory. This plist file is loaded thus without any problems: NSDictionary *sqlPropertyList = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:CH_PQ_QUERIES ofType:@"plist"]]; I created a .txt file in the same directory and t...

Organization of many bundles (like System Preferences.app)

I'm working on a project which organizes many separate bundles onto a System Preferences-like screen, in categories. First, how does System Preferences organize its pref panes into categories? A quick glance in the pref panes' bundles reveals no obvious category info. Second, how should I organize my bundles into categories? Right now,...

How to retain an window without holding a pointer to it in garbage collected Obj-C?

I am currently working through the famous "Cocoa Programming for OSX" by Aaron Hillegaas. In Chapter 12 he wants me to create an about window using [BOOL] successful = [NSBundle loadNibNamed:@"About" owner:self]; which, by itself, works perfectly well. However, I am using the garbage collector and since I do not retain a pointer to t...

UIWebView to Play Local and downloaded Video

I want to play downloaded video using UIWebview. I get webkiterrordomain code=204 error. but if i play video from resources folder it run perfect. //from resources folder run perfect NSString *tempurl = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"video.mp4"]; //from downloaded file NSString *tempurl = dow...

Iphone SDK: pathFoResource:Nsstring problem -> playin MP3 files

I am trying to get 10 mp3 files in the resources folder and play them when a button is pressed. I have entered name of the mp3 files in a NSMutableArray and read each one after the button is pressed. The problem is that pathForResource: is not working (returns nil). If i use the file name explicitly -like pathFoResource:@"song1.mp3" ofT...

Symbolizing plugins in Instruments' stack traces

Instruments is able to properly symbolize my app's main bundle (as well as frameworks and libraries) in the stack trace of the extended detail view. However, symbols aren't resolved for plugins loaded during execution. Setting the build directory where the dSym files for the main and plugin bundles are located (as well as the app itself...

Loading NIB using [NSBundle loadNibNamed:owner:] but the window does not appear in the foreground

I wrote a menu application that has no persistent window or standard menu. When another application has focus and I use the menulet to trigger a window to be opened, it appears behind the foreground application (but above anything else that is present on the screen). Basically... -(IBAction)aboutWindow:(id)sender { [NSBundle loadNi...