Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何编写将指针地址作为参数的方法?_Objective C - Fatal编程技术网

Objective c 如何编写将指针地址作为参数的方法?

Objective c 如何编写将指针地址作为参数的方法?,objective-c,Objective C,使用NSString类方法stringWithContentsOfFile:encoding:错误我可以: NSError *error; NSString *fileContent = [NSString stringWithContentsOfFile:... encoding:... error:&error] if (fileContent == nil) { NSLog(@"%@", error); } 我想做一些类似的事情,大致如下: NSString *message

使用NSString类方法stringWithContentsOfFile:encoding:错误我可以:

NSError *error;
NSString *fileContent = [NSString stringWithContentsOfFile:... encoding:... error:&error]
if (fileContent == nil) {
  NSLog(@"%@", error);
}
我想做一些类似的事情,大致如下:

NSString *message;
BOOL result =  [self checkSomeRandomStuff:&message];
if (result == NO) {
  NSLog(@"%@", message);
}

如何在checkSomeRandomStuff方法中分配消息变量?

向参数类型添加另一个*

-(BOOL)checkSomeRandomStuff:(NSString**)message {
  // check some random stuff
  if (something) {
    *message = @"something";
    return YES;
  } else {
    *message = @"some other thing";
    return NO;
  }
}

将另一个*添加到参数类型

-(BOOL)checkSomeRandomStuff:(NSString**)message {
  // check some random stuff
  if (something) {
    *message = @"something";
    return YES;
  } else {
    *message = @"some other thing";
    return NO;
  }
}