내 문제를 heres. 나는 그것의 간단한 것을 추측하지만 나는 이것이 작동하지 않는 이유를 알 수 없다.다른 클래스의 콘센트에 액세스
다른 클래스 (ServiceController)의 한 클래스 (RootViewController)에서 Outlets (UITextField, UITableView, UIActivityIndicatorView 등)에 액세스해야합니다.
나는 (만하면 무슨 표시) 현재이 있습니다
RootViewController.h
@interface RootViewController : UIViewController{
UITextField *textField;
}
@property (nonatomic, retain) IBOutlet UITextField *textField;
- (void)startService;
@end
RootViewController.m
@implementation RootViewController
@synthesize textField;
- (void)startService{
ServiceController *service = [[ServiceController alloc] init];
[service start];
[service release];
}
@end
ServiceController.h
@class RootViewController;
@interface ServiceController : NSObject{
}
@property (nonatomic, retain) IBOutlet RootViewController *rootViewController;
- (void)start;
@end
서비스 Controller.m
#import "RootViewController.h"
@implementation ServiceController
@synthesize rootViewController;
- (void)start{
[((RootViewController*)rootViewController).textField setText:@"HELLO !"];
NSLog(@"CALLED !");
}
@end
이 작동하지 않는 이유가 표시되지 않습니다, 나는 DetailViewController에 RootViewController에서 같은 일을 같은 방법을 사용하고 그것을 잘 작동합니다. 나는 세부 사항/루트 컨트롤러에 다른 선언이 있는지 확인하여 작동하도록했으나 아무 것도 알지 못했습니다.
추신 : 모든 것이 성공적으로 호출되었으며 "전화를 겁니다!" 내가 콘센트에 무엇을 하든지 영향을 미치지 않습니다.
은 ServiceController는 XIB 파일에 제대로 RootViewController에 연결되어 있습니까? – Luke
서비스 컨트롤러에 XIB 파일이 없습니다. 도움이된다면, 코드 완성은 입력하는 동안 rootViewController의 모든 메소드와 아웃렛을 인식하며 경고가 없습니다. rootViewController에 ServiceController에 대한 IBOutlet이 필요합니까? – Lost
아니요 - ServiceController의 rootViewController 속성을 설정해야합니다. XIB 파일에서 또는 코드에서 명시 적으로이 작업을 수행 할 수 있습니다. myServiceController.rootViewController = myRootViewController; – Luke