我有一个生成随机字符串的快速功能
.h
@interface ICObjects : NSObject
+(void)certRef:(NSString *)randomCertRef;
.m
@implementation ICObjects
+(void)certRef:(NSString *)randomCertRef{
NSLog(@"REF PRESSED");
NSInteger rNumber = arc4random() % 100000000 + 1;
randomCertRef = [NSString stringWithFormat: @"V/R %d", rNumber];
NSLog(@"REF RESULT %@",randomCertRef);
}
在我的观点中回顾它似乎是在逃避我
self.mytextString = [ICObjects certRef.text];
("预期"])
self.mytextString = [[ICObjects certRef ]text];
("没有已知的类方法"])
答案 0 :(得分:1)
好吧,你的函数不会使用参数randomCertRef
,因为你覆盖了它。所以我的猜测是你想要这样的东西:
+(NSString*)certRef
{
NSLog(@"REF PRESSED");
NSInteger rNumber = arc4random() % 100000000 + 1;
NSString *randomCertRef = [NSString stringWithFormat: @"V/R %d", rNumber];
NSLog(@"REF RESULT %@",randomCertRef);
return randomCertRef;
}
这样使用:
self.mytextString = [ICObjects certRef];