Cocoa Filename Question
Is is possable to find out where the app bundle is located? If so there how would you get the file refrence to the folder that the app is in?
if not... cocoa sucks :ouch:
[edit] also how do you load the file names from a folder into adn array and get the # of files in the folder?
if not... cocoa sucks :ouch:
[edit] also how do you load the file names from a folder into adn array and get the # of files in the folder?
Just replace the JString with a char* I believe.
Code:
CFStringRef str;
JString returnval;
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef bundleLocation = CFBundleCopyBundleURL(mainBundle);
str = CFURLCopyPath(bundleLocation);
returnval = CFStringGetCStringPtr(str,kCFStringEncodingMacRoman);
Code:
NSBundle *bundle = [NSBundle mainBundle];
//to get a particular file in the bundle's resources:
NSString *path1 = [bundle pathForResource:@"readme" ofType:@"txt"];
//to get a file in a subdir:
NSString *path2 = [bundle pathForResource:@"level2" ofType:@"txt" inDirectory:@"levels"];
//to get just the path to the resources:
NSString *toppath = [bundle resourcePath];
//to get that array of files in your resource directory:
NSArray *files = [[NSFileManager defaultManager] directoryContentsAtPath:toppath];
make sense?
---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Um.. Actually I'm wonderhing how to get... Oh never mind
. That'll do. Thanks!

Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
Newbie question: Cocoa and Carbon - which for what and how to get started? | BliTz | 3 | 5,160 |
Jul 27, 2006 10:07 PM Last Post: OneSadCookie |
|
Cocoa/Objective-C Question | infernooo | 2 | 4,344 |
Oct 18, 2005 11:26 PM Last Post: infernooo |
|
Quick threaded OpenGL drawing question in Cocoa | TomorrowPlusX | 2 | 5,088 |
Nov 11, 2004 05:23 AM Last Post: TomorrowPlusX |
|
Cocoa: Tile Question | Criollo | 15 | 9,693 |
Oct 3, 2003 02:02 AM Last Post: Criollo |
|
Cocoa Question | Jake | 7 | 6,201 |
Jun 2, 2003 07:03 PM Last Post: Feanor |