独学で iOS プログラミングを学び、この本に従うことから始めます。「タイプ 'AppDelegate *' のオブジェクトにプロパティ 'MainViewController' が見つかりません」というエラーが発生しました。
コードに正しく従っていることを 2 回、3 回チェックしました。私は StackOverflow を精査し、いくつかの解決策を試しましたが、どれも機能せず、問題に適切に一致するものはほとんどありませんでした。何か助けはありますか?
AppDelegate.m (エラーの場所)
#import "AppDelegate.h"
#import "WeatherForecast.h"
#import "MainViewController.h"
@implementation AppDelegate
@synthesize managedObjectContext = _managedObjectContext;
@synthesize managedObjectModel = _managedObjectModel;
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
WeatherForecast *forecast = [[WeatherForecast alloc] init];
self.MainViewController.forecast = forecast;
// Override point for customization after application launch.
MainViewController *controller = (MainViewController *)self.window.rootViewController;
controller.managedObjectContext = self.managedObjectContext;
return YES;
}
MainViewController.h
#import "FlipsideViewController.h"
#import "WeatherForecast.h"
#import <CoreData/CoreData.h>
@interface MainViewController : UIViewController <FlipsideViewControllerDelegate>
- (IBAction)showInfo;
- (IBAction)refreshView:(id) sender;
- (void)updateView;
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (strong, nonatomic) WeatherForecast *forecast;
@end