我写了这个函数RootViewController.appRecord是一个包含XML属性的对象.
- (NSString*) getString:(int)row{
AppRecord *appRecord = [self.entries objectAtIndex:row];
NSString *appName = appRecord.appName;
return appName;
}
Run Code Online (Sandbox Code Playgroud)
我想通过写这个来再次使用这个函数:
RootViewController *record = [RootViewController new];
NSString *appsName = [record getString:0];
NSLOG(appsName);
Run Code Online (Sandbox Code Playgroud)
编译之后,它没有返回任何内容,但是appsName如果我在RootViewControllerclass([self getString:0])中使用这个函数它会工作并返回,所以我知道函数没有问题.当我尝试更改return appName为return @"test",当我从另一个类访问它时,它工作并返回了一些东西.
这意味着这有问题appRecord; 它是在类中返回的,但是当我从另一个类访问它时没有返回任何内容.
如何解决这个问题呢?