Re: writeToFile:atomically ... again
Re: writeToFile:atomically ... again
- Subject: Re: writeToFile:atomically ... again
- From: "Nima Talebi" <email@hidden>
- Date: Mon, 11 Jun 2007 11:25:45 +1000
Thankyou for everyone who's replied...
murat: I've already proven that I can in the test case, and in the ls -ld of
/tmp/
Tommy: Permission 1777 means all can read/write in that directory, the
sticky bit protects each user from other users.
---
Stephen:
Thankyou, I'm not sure what I did, but I just attempted a NSString as key
again (or perhapse for the first time as it makes no sense) and it does
work. I can't find where it says the key has to be a String but will look
again, I'm sure as you say it's in there somewhere.
I've taken your advice on NSLog and the printf vulnerability (Which I still
don't know about). I'm still making my way through Hillegass =)
The casting was one of those ...`I'm going crazy, I'll make everything
explicite, try anything' moments.
Nima
On 6/11/07, stephen joseph butler <email@hidden> wrote:
On 6/10/07, Nima Talebi <email@hidden> wrote:
> Problem Method: [NSDictionary writeToFile:atomically:] fails everytime,
and
> I don't know why.
>
> Test Case: I've pasted the original email here...
> http://dark-code.bulix.org/f0dcgo-44875?raw
>
> Results/Problem:
> As you can see, the writeToFile:atomically works perfectly fine for
NSArray
> of NSNumbers and NSStrings, however the resultant NSDictionary fails.
When serializing a dictionary can only contain strings for keys. I
swear that the docs say this somewhere, but I can't find it at the
moment. Anyway, this code works for me in the example where I use
strings for keys:
<https://netfiles.uiuc.edu/sbutler1/www/atomic-test.m>. You say you
tested strings for keys, but I don't know why that's failing for you.
There were a couple things I noticed about your code, however:
> NSLog([someKeys description]); //An NSArray of NSNumbers
This is very bad practice and opens you up for printf vulnerabilities.
The way you should do it is this:
NSLog( "@%", someKeys );
or even better:
NSLog( @"someKeys = %@", someKeys );
> entries = (NSDictionary*)
> [NSDictionary
> dictionaryWithObjects:(NSArray*)someValues
> forKeys:(NSArray *)someKeys];
I don't understand why you are casting here.
+dictionaryWithObjects:forKeys: returns an NSDictionary*. Also, if
someValues and someKeys aren't NSArray's then you shouldn't be passing
them as parameters.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden