ここで何が間違っているのかわかりません。私はまた、以下を使用して設定s1..3
を試みましfoo
た:
s1 = [[NSString alloc] initWithString:[filepaths objectAtIndex:0]];
以下のコンテキスト:
void foo(NSString *s1, NSString *s2, NSString *s3){
//assign long string to NSString *fps
//...
//break fps into smaller bits
NSArray *filepaths = [fps componentsSeparatedByString:@"\n"];
//the above worked! now let's assign them to the pointers
s1 = [filepaths objectAtIndex:0];
//repeat for s2 and s3
NSLog(@"%@",s1); //it worked! we're done in this function
}
int main(int argc, const char * argv[]){
NSString *s1 = nil; //s2 and s3 as well
foo(s1,s2,s3); //this should work
NSLog(@"%@",s1); //UH OH, this is null!
return 0;
}