ios - I get the error Property '...' not found on object of type '...' -
appdelegate.h
#import <uikit/uikit.h> @interface appdelegate : uiresponder <uiapplicationdelegate> @property (strong, nonatomic) uiwindow *window; @end
appdelegate.m
#import "appdelegate.h" #import "firstviewcontroller.h" #import "secondviewcontroller.h" @implementation appdelegate - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions: goes on normal app.......... @end
firstviewcontroller.h
#import <uikit/uikit.h> @interface firstviewcontroller : uiviewcontroller @property (strong, nonatomic) iboutlet uiimageview *bground; - (ibaction)settingspressed:(id)sender; - (ibaction)startpressed:(id)sender; @end @class secondviewcontroller; @interface secondviewcontroller : uiviewcontroller @property(strong,nonatomic)secondviewcontroller *secondviewcontroller; @end
firstviewcontroller.m
#import "firstviewcontroller.h" @interface firstviewcontroller () @end @implementation firstviewcontroller - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } - (ibaction)settingspressed:(id)sender {
on line says "property 'secondviewcontroller' not found on object of type 'firstviewcontroller' it's line directly below.
self.secondviewcontroller = [[secondviewcontroller alloc] initwithnibname:@"secondviewcontroller" bundle:nil];
it has same warning last on line below.
[self presentviewcontroller:self.secondviewcontroller animated:yes completion:nil]; } - (ibaction)startpressed:(id)sender { } @end
secondviewcontroller.h
#import <uikit/uikit.h> @interface secondviewcontroller : uiviewcontroller @end
secondviewcontroller.m
#import "secondviewcontroller.h" @interface secondviewcontroller () @end @implementation secondviewcontroller - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view. } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } @end
i'm confused why declaring secondviewcontroller twice. seem both in firstviewcontroler.h , in own .h file. regardless, issue seems have given secondviewcontroller property trying access. reread own code:
@interface secondviewcontroller : uiviewcontroller @property(strong,nonatomic)secondviewcontroller *secondviewcontroller; @end
what want in firstviewcontroller.h file this:
#import <uikit/uikit.h> #import "secondviewcontroller.h" @interface firstviewcontroller : uiviewcontroller @property (strong, nonatomic) iboutlet uiimageview *bground; @property(strong,nonatomic)secondviewcontroller *secondviewcontroller; - (ibaction)settingspressed:(id)sender; - (ibaction)startpressed:(id)sender; @end
note import secondviewcontroller @ top of .h file, , declare property inside @interface.
Comments
Post a Comment