i'm trying read file relative pathname, it's not working.
can me out?
thanks.
code:
- (void) drawrect:(nsrect)dirtyrect { nsstring *directory = @"."; directory = [directory stringbystandardizingpath]; nsstring *filename = @"/logo.png"; nsstring *string = [nsstring stringwithformat:@"%@%@%@", @"file://localhost/", directory, filename]; nsurl *url = [[nsurl alloc] initwithstring:string]; nsdata *data = [nsdata datawithcontentsofurl:url]; <<< data nil <<<
display resulting string, before make url. confirm file exists @ location. post result.
since you're referring file on localhost, can avoid url entirely , use 1 of nsdata methods returns contents of file given pathname string.
there nsdata methods return nserror reference. might use 1 of those, , use nserror or sub-components give more detail on problem is.
Forums Macs Mac Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
Comments
Post a Comment