I know there’s another question like this on stack overflow, but my problem is from my own class not a UIButton. My method is a lot more complicated. The first commented line works.
@implementation GettingStartedViewController
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex {
//[cui showHelpClickButtonAtIndex:buttonIndex:self.view:
//theController:FALSE:HelpPageGettingStarted];
// Error from this next line error: object cannot be set - either
//readonly property or no setter found
self.theController = [cui showHelpClickButtonAtIndex:buttonIndex:
self.view:theController:FALSE:HelpPageGettingStarted];
}
- (void)viewDidLoad {
[super viewDidLoad];
cui = [CommonUI alloc]; // Used for several functions
}
And heres the function it calls. I’ve trying to reuse code and keep things in one function. the function uses addSubView and presentModalViewController.
@implementation CommonUI
-(UIViewController *)showHelpClickButtonAtIndex:(int)buttonIndex:
(UIView *)vw:(UIViewController *)vc:(BOOL)useNav:(HelpPage)page{
if (buttonIndex == CommonUIInfoHelpPagesBtnIdx) {
if (useNav == TRUE) {
// snip
} else {
vc = [[HelpViewController alloc] initWithNibName:@"HelpView"
bundle:nil onPage:page];
[vw addSubview:vc.view];
return [vc autorelease];
}
} else {
// Snip
}
// Snip
}
The message says that there is no property for
theControllerinGettingStartedViewController. Your method call works just fine.self.theController = someObjectis the same as calling the setter method:[self setTheController:someObject]Properties automatically generate those getters and setters; so if you did not define a property, it is not going to create a setter and this is your problem here.
Add the following to your header file:
And synthesize it in your implementation file:
Do not forget to release it in the
-deallocmethod, as you told the setter to retain the object: