if( [data count] == 0 )
do this;
----
So it looks like arrayWithContentsOfFile: is returning an empty
array when file.plist doesn't exist.
Note that the test for [data count] == 0 will work as a test whether
the method returns nil or an
On 2009-10-13, at 13:27 , I. Savant wrote:
So that's exactly how the code appears?
Yes. But of course I have to look in the directory before the code
runs. So the file must be created somewhere before processing gets to
this point.
I created a test application with just this code in it,
On Oct 13, 2009, at 3:52 PM, DKJ wrote:
NSArray *data;
data = [NSArray arrayWithContentsOfFile:[NSHomeDirectory()
stringByAppendingPathComponent:@"/Documents/file.plist"]];
if( data == nil )
do this;
DKJ wrote:
NSArray *data;
data = [NSArray arrayWithContentsOfFile:[NSHomeDirectory()
stringByAppendingPathComponent:@"/Documents/file.plist"]];
I would have used @"Documents/file.plist" as the parameter there. Your
way, I wonder if you'd end up with a double slash
Hmm... I ran a similar code snippet in another project, and nil is
returned, as the docs say.
So the file must be created somewhere else. I'll find out where.
I'm glad the docs aren't wrong.
dkj
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com
On 2009-10-13, at 12:35 , I. Savant wrote:
Again, can you post your relevant code?
NSArray *data;
data = [NSArray arrayWithContentsOfFile:[NSHomeDirectory()
stringByAppendingPathComponent:@"/Documents/file.plist"]];
if( data == nil )
On Oct 13, 2009, at 3:23 PM, DKJ wrote:
On 2009-10-13, at 12:12 , I. Savant wrote:
Let me see if I understand what you're saying: You are expecting
there to be *no* PLIST files (and so, you expect to get nil) but
are getting an empty array?
Bingo.
Again, can you post your relevant c
On 2009-10-13, at 12:12 , I. Savant wrote:
Let me see if I understand what you're saying: You are expecting
there to be *no* PLIST files (and so, you expect to get nil) but are
getting an empty array?
Bingo.
___
Cocoa-dev mailing list (Cocoa-de
On Oct 13, 2009, at 3:08 PM, DKJ wrote:
I looked in the directory itself before running the code, and the
plist files weren't there at all.
Let me see if I understand what you're saying: You are expecting
there to be *no* PLIST files (and so, you expect to get nil) but are
getting an
On 2009-10-13, at 12:01 , I. Savant wrote:
On Oct 13, 2009, at 2:54 PM, Jens Alfke wrote:
A PLIST can have an array root or a dictionary root. Are you sure
your PLIST has an array root? I would still expect nil (ie, it can't
create an array from a dictionary-rooted PLIST), but it's worth
On Oct 13, 2009, at 2:54 PM, Jens Alfke wrote:
The docs say it returns nil if the file doesn't exist, and he's
getting an empty array. That was his question.
...
You must have misread his code — he's using NSHomeDirectory() as a
prefix.
My apologies, you're absolutely right. I read that
On Oct 13, 2009, at 11:49 AM, I. Savant wrote:
Nope. The docs are correct and I'm betting the file you specified
in fact *doesn't* exist.
The docs say it returns nil if the file doesn't exist, and he's
getting an empty array. That was his question.
"/Documents/file.plist" is probably n
On Oct 13, 2009, at 2:43 PM, DKJ wrote:
I'm using this code to read an array from a plist:
NSArray *data = [NSArray arrayWithContentsOfFile:[NSHomeDirectory()
stringByAppendingPathComponent:@"/Documents/file.plist"]];
The docs say this method returns nil when the fil
I'm using this code to read an array from a plist:
NSArray *data = [NSArray arrayWithContentsOfFile:[NSHomeDirectory()
stringByAppendingPathComponent:@"/Documents/file.plist"]];
The docs say this method returns nil when the file doesn't exist
(precisely: "Returns
14 matches
Mail list logo