• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: What causes NSFileManager's stringWithFileSystemRepresentation to return nil?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What causes NSFileManager's stringWithFileSystemRepresentation to return nil?


  • Subject: Re: What causes NSFileManager's stringWithFileSystemRepresentation to return nil?
  • From: Andy Lee <email@hidden>
  • Date: Tue, 26 Oct 2010 08:08:57 -0400

On Oct 26, 2010, at 7:29 AM, G S wrote:
> Hi all.  I'm giving this function what appears to be a perfectly good path:
>
> /Users/me/Library/Application Support/iPhone
> Simulator/4.2/Applications/58BD5465-FD47-49E3-83AC-242961559F48/Library/Caches/4320_th.jpg
>
> and it returns nil.

Using the exact string above, this works fine for me:

	char *cp = "/Users/me/Library/Application Support/iPhone Simulator/4.2/Applications/58BD5465-FD47-49E3-83AC-242961559F48/Library/Caches/4320_th.jpg";
	NSString *s = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:cp length:strlen(cp)];
	NSLog(@"cp is [%s]", cp);
	NSLog(@"s is [%@]", s);

I get:

2010-10-26 08:02:23.877 Scratcho[3862:a0f] cp is [/Users/me/Library/Application Support/iPhone Simulator/4.2/Applications/58BD5465-FD47-49E3-83AC-242961559F48/Library/Caches/4320_th.jpg]
2010-10-26 08:02:23.878 Scratcho[3862:a0f] s is [/Users/me/Library/Application Support/iPhone Simulator/4.2/Applications/58BD5465-FD47-49E3-83AC-242961559F48/Library/Caches/4320_th.jpg]

Show us your exact code.  Is your C string null-terminated?  Does strlen() return the number of characters you'd expect?  Try logging the C string as I did above (I put the square brackets around it to make sure I spot any leading or trailing whitespace).

I ran my code in a Cocoa app, not the iPhone simulator, but offhand I can't think of a reason that NSFileManager method would be different on the two platforms.

--Andy


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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

  • Follow-Ups:
    • Re: What causes NSFileManager's stringWithFileSystemRepresentation to return nil?
      • From: G S <email@hidden>
References: 
 >What causes NSFileManager's stringWithFileSystemRepresentation to return nil? (From: G S <email@hidden>)

  • Prev by Date: Re: What causes NSFileManager's stringWithFileSystemRepresentation to return nil?
  • Next by Date: Choosing a correct font size when resizing
  • Previous by thread: Re: What causes NSFileManager's stringWithFileSystemRepresentation to return nil?
  • Next by thread: Re: What causes NSFileManager's stringWithFileSystemRepresentation to return nil?
  • Index(es):
    • Date
    • Thread