Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-13-2011, 01:34 AM   #1 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 35
scrumsolutions is on a distinguished road
Wink Getting plist path

Hi All,

I've added a plist for managing all of my settings through the settings area. I have two questions;

1. I can get my bundle path, but I don't seem to be able to reference my plist. I have tried the following;

Code:
NSString *filePath = [NSBundle mainBundle] && @"root.plist";
And;

Code:
NSString *path = [[NSBundle mainBundle] pathForResource:
    @"root" ofType:@"plist"];
If I remove any reference to the plist, I can return the application path using just;

Code:
NSString *filePath = [NSBundle mainBundle]
And my second question, is data saved in the plist persistant? Or do I need to store values in a DB, XML, etc?

Cheers

Carl
scrumsolutions is offline   Reply With Quote
Old 06-13-2011, 01:38 AM   #2 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Quote:
Originally Posted by scrumsolutions View Post
Hi All,

I've added a plist for managing all of my settings through the settings area. I have two questions;

1. I can get my bundle path, but I don't seem to be able to reference my plist. I have tried the following;

Code:
NSString *filePath = [NSBundle mainBundle] && @"root.plist";
And;

Code:
NSString *path = [[NSBundle mainBundle] pathForResource:
    @"root" ofType:@"plist"];
If I remove any reference to the plist, I can return the application path using just;

Code:
NSString *filePath = [NSBundle mainBundle]
And my second question, is data saved in the plist persistant? Or do I need to store values in a DB, XML, etc?

Cheers

Carl
Took this straight from my code:
Code:
 NSString *PlistPath = [[NSBundle mainBundle] pathForResource:@"plistFile" ofType:@"plist"];
Then you use the path like this: (lets assume its an array)
Code:
NSArray *plistArray = [NSArray arrayWithContentsOfFile:PlistPath];
Also, why don't you just save your plist data container object to NSUserDefaults?
Domele is offline   Reply With Quote
Old 06-13-2011, 01:54 AM   #3 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 35
scrumsolutions is on a distinguished road
Default Still returning nil

Hi,

I tried;

Code:
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"root" ofType:@"plist"];
    NSArray *plistArray = [NSArray arrayWithContentsOfFile:filePath];
But both the filepath string and the array return nil. My root.plist is in the root directory of the application.

Cheers

Carl
scrumsolutions is offline   Reply With Quote
Old 07-10-2011, 09:23 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 2
msukang is on a distinguished road
Default

Here is a similar case:

NSString* candleOnPath = [[NSBundle mainBundle] pathForResource:@"candle on" ofType:@"jpg"];

NSLog(candleOnPath);

candleOnImage = [[UIImage alloc] initWithContentsOfFile:candleOnPath];

if (candleOnImage)
NSLog(@"Image not null..");

NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"Drink" ofType:@"plist"];
NSLog(plistPath);

NSMutableArray* tmpArray = [[NSMutableArray alloc] initWithContentsOfFilelistPath];

if (tmpArray)
NSLog(@"tmpArray not null..");
else
NSLog(@"tmpArray null..");

The results are as follows:

2011-07-11 10:44:33.186 LightTheCandle[13756:207] /Users/cse/Library/Application Support/iPhone Simulator/4.3.2/Applications/FDF27D59-F508-4D31-BCB1-4EA73D7E55DE/LightTheCandle.app/candle on.jpg
2011-07-11 10:44:33.189 LightTheCandle[13756:207] Image not null..
2011-07-11 10:44:33.190 LightTheCandle[13756:207] /Users/cse/Library/Application Support/iPhone Simulator/4.3.2/Applications/FDF27D59-F508-4D31-BCB1-4EA73D7E55DE/LightTheCandle.app/Drink.plist
2011-07-11 10:44:33.191 LightTheCandle[13756:207] tmpArray null..

--------------
Any Idea why Drinl.plist returns null while candle.jpg doesn't.
(The related files are well located in the supporting files.)

What did I do wrong??
msukang is offline   Reply With Quote
Reply

Bookmarks

Tags
application path, plist

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 317
6 members and 311 guests
chemistry, Dnnake, iOS.Lover, lendo, Leslie80, pbart
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,664
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Leslie80
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:23 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0