我不确定我在这里做错了什么。我也尝试过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;
}