我从 nsobject 类回调我的 viewController 时遇到问题。这是我的代码:
视图控制器:
-(void)startTest:(NSString*)testToRun
{
ViewController *ViewController = [[[ViewController alloc] init] autorelease];
SecondClass *secondClass = [[SecondClass alloc] init];
secondClass.viewController = viewController;
[secondClass doSomething];
}
-(void) createView
{
UIView *newView = [UIView alloc] initWithFrame:[self.view bounds];
self.newView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:newView];
[self.view bringSubviewToFront:newView]
}
NSObject classe:
.h file
#import "ViewController.h"
@class ViewController;
@interface SecondClass : NSObject
{
ViewController *viewController;
}
@property (nonatomic,retain) ViewController *viewController;
-(void) doSomething;
.m file
-(void) doSomething
{
[viewController createView];
}
你们中的任何人都可能知道我做错了什么,或者如何从我的 nsobject 类中回调我的视图控制器?