 |
 |
|
 |
03-20-2010, 10:50 AM
|
#1 (permalink)
|
|
Obj-C Learner
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
|
Unrecognized selector sent to instance
Code:
[fileTemplate writeToFile:writablePath atomically:YES encoding:NSUTF8StringEncoding error:NULL];
This is the line in question.
Just for clarity:
Code:
fileTemplate = [NSString stringWithFormat:@"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n<title>Untitled Document</title>\n</head>\n\n<body>\n</body>\n</html>"];
and
Code:
WritablePath = [NSString stringWithFormat:@"/Users/Prince/Library/Application Support/iPhone Simulator/3.2/Applications/3A8069CB-526D-4F65-9F29-8939B250431E/Documents/Project/index.txt"];
Obviously WritablePath uses a different way to get the path, but I NSLogged it, and got that...
__________________
Will code for food
|
|
|
03-20-2010, 11:01 AM
|
#2 (permalink)
|
|
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
|
Check your capitalisation, you're passing "writablePath" with a lowercase w, yet your NSString pointer is "WritablePath" with an uppercase w.
Also, you don't have to use stringWithFormat unless you're actually formatting something.
For example, you can just use:
Code:
WritablePath = @"/Users/Prince/Library/Application Support/iPhone Simulator/3.2/Applications/3A8069CB-526D-4F65-9F29-8939B250431E/Documents/Project/index.txt";
|
|
|
03-20-2010, 11:15 AM
|
#3 (permalink)
|
|
Obj-C Learner
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
|
Quote:
Originally Posted by harrytheshark
Check your capitalisation, you're passing "writablePath" with a lowercase w, yet your NSString pointer is "WritablePath" with an uppercase w.
Also, you don't have to use stringWithFormat unless you're actually formatting something.
For example, you can just use:
Code:
WritablePath = @"/Users/Prince/Library/Application Support/iPhone Simulator/3.2/Applications/3A8069CB-526D-4F65-9F29-8939B250431E/Documents/Project/index.txt";
|
Ah, that would throw me a compile error, I just had to edit the method names because some people wouldn't approve.
I'll try that thing.
__________________
Will code for food
|
|
|
03-20-2010, 11:17 AM
|
#4 (permalink)
|
|
Obj-C Learner
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
|
It worked, I have no idea why though.
How would I check when the operation has been completed?
__________________
Will code for food
|
|
|
03-21-2010, 12:49 PM
|
#5 (permalink)
|
|
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
|
It returns a BOOL, so you can use:
Code:
BOOL didSucceed = [whatever writeToFile...];
if (didSucceed){
NSLog(@"yep");
}
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 267 |
| 17 members and 250 guests |
| ADY, Alsahir, dacapo, Dani77, Desert Diva, Duncan C, F_Bryant, Grinarn, HemiMG, jansan, linkmx, M@realobjects, macquitzon216, prchn4christ, smethorst, spiderguy84 |
| Most users ever online was 1,187, 10-11-2011 at 08:09 AM. |
» Stats |
Members: 158,882
Threads: 89,228
Posts: 380,761
Top Poster: BrianSlick (7,129)
|
| Welcome to our newest member, jansan |
|