带参数的语法错误调用方法
Syntax error calling method with argument
我正在尝试调用一个带有参数但语法不正确的方法。有人可以看到我做错了什么吗?精确的误差是"Use of Undeclared Identifier 'self'"。
- (NSString*)uniquePicName:(NSString *)extensionString
{
// Extension string is like @".png"
NSDate *time = [NSDate date];
NSDateFormatter* df = [NSDateFormatter new];
[df setDateFormat:@"dd-MM-yyyy-hh-mm-ss"];
NSString *timeString = [df stringFromDate:time];
NSString *fileName = [NSString stringWithFormat:@"File-%@%@", timeString, extensionString];
return fileName;
}
NSString *extension = @".png";
NSString *newName = [self uniquePicName:extension]//throws error here
语句:
NSString *extension = @".png";
NSString *newName = [self uniquePicName:extension];
必须在 class.
的方法中
如果语句不在方法中 self
不存在,您将收到消息:"Use of Undeclared Identifier 'self'".
我正在尝试调用一个带有参数但语法不正确的方法。有人可以看到我做错了什么吗?精确的误差是"Use of Undeclared Identifier 'self'"。
- (NSString*)uniquePicName:(NSString *)extensionString
{
// Extension string is like @".png"
NSDate *time = [NSDate date];
NSDateFormatter* df = [NSDateFormatter new];
[df setDateFormat:@"dd-MM-yyyy-hh-mm-ss"];
NSString *timeString = [df stringFromDate:time];
NSString *fileName = [NSString stringWithFormat:@"File-%@%@", timeString, extensionString];
return fileName;
}
NSString *extension = @".png";
NSString *newName = [self uniquePicName:extension]//throws error here
语句:
NSString *extension = @".png";
NSString *newName = [self uniquePicName:extension];
必须在 class.
的方法中如果语句不在方法中 self
不存在,您将收到消息:"Use of Undeclared Identifier 'self'".