nsstring - Objective-C file i/o error -
nsstring - Objective-C file i/o error -
- (ibaction)sendmessage:(id)sender { nsstring* conversationfile = [@"~/" stringbyappendingpathcomponent:@"conversation.txt"]; bool fileexists = [[nsfilemanager defaultmanager] fileexistsatpath:conversationfile]; if (fileexists == false) { [self doshellscript:@"do shell script \"cd ~/; touch conversation.txt\""]; } nsstring *conversationcontent = [[nsstring alloc] stringwithcontentsoffile:@"~/conversation.txt" encoding:nsutf8stringencoding error:null]; nsstring *mymessage = [[messagebox stringvalue]copy]; nsstring *combinedcontent = [nsstring stringwithformat:@"%@ \r\n %@", conversationcontent, mymessage]; [[[myconversationbox textstorage] mutablestring] setstring: combinedcontent]; [combinedcontent writetofile:@"~/conversation.txt" atomically:yes encoding:nsutf8stringencoding error:null]; }
the above code presents next error
2011-07-07 21:38:08.703 imessages[86493:903] -[nsplaceholderstring stringwithcontentsoffile:encoding:error:]: unrecognized selector sent instance 0x100111690
2011-07-07 21:38:08.704 imessages[86493:903] -[nsplaceholderstring stringwithcontentsoffile:encoding:error:]: unrecognized selector sent instance 0x100111690
stringwithcontentsoffile:encoding:error: class method of nsstring, not instance method, don't need (shouldn't) alloc first.
nsstring *conversationcontent = [nsstring stringwithcontentsoffile:@"~/conversation.txt" encoding:nsutf8stringencoding error:null]; objective-c nsstring io filehandle
Comments
Post a Comment