Xcode Interface Builder не показывает объект делегата приложения

Я обучаю себя программированию на Objective-C и iOS с помощью «Программирование на iOS: руководство Big Nerd Ranch (2-е издание)», и я столкнулся с проблемой, когда в учебном пособии требуется, чтобы я создавал подключения к объекту делегата приложения, но этот объект не отображается в списке объектов в построителе интерфейсов для меня. Я почти уверен, что это либо опечатка, либо другая версия, поскольку книга немного отстает от моей версии Xcode (4.2). Я включил код. Я почти уверен, что объект MOCAppDelegate - это то, что должно отображаться в IB, но я еще недостаточно знаком, чтобы знать, какие изменения кода мне нужны, чтобы это произошло. Конкретный вопрос: как мне настроить приведенный ниже код, чтобы я получил объект в списке объектов в IB, чтобы я мог выполнять соединения в соответствии с инструкциями в графическом руководстве?

Примечание: я исследовал и нашел это: Возникли проблемы с подключением переменных экземпляра к AppDelegate , но это решение не сработало для меня (или я реализовал его неправильно)

ScreenShot Заголовочный файл

#import 
#import 
#import 

@interface MOCAppDelegate : UIResponder 
{
    CLLocationManager *locationManager;

    IBOutlet MKMapView *worldView;
    IBOutlet UIActivityIndicatorView *activityIndicator;
    IBOutlet UITextField *locationTitleField;
}

@property (strong, nonatomic) IBOutlet UIWindow *window;


@end

Файл реализации

#import "MOCAppDelegate.h"

@implementation MOCAppDelegate

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //Create location manager object
    locationManager = [[CLLocationManager alloc] init];
    [locationManager setDelegate:self];

    //We want all results from the location manager
    [locationManager setDistanceFilter:kCLDistanceFilterNone];

    //And we want it to be as accurate as possible
    //regardless of how much time/power it takes
    [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];

    //Tell our location manager to start looking for it location immediately
    [locationManager startUpdatingLocation];

    //We also want to know our heading
    if (locationManager.headingAvailable == true) {
        [locationManager startUpdatingHeading];
    }


    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor darkGrayColor];
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
{
    NSLog(@"%@", newLocation);
}

- (void)locationManager:(CLLocationManager *)manager
       didUpdateHeading:(CLHeading *)newHeading
{
    NSLog(@"%@", newHeading);
}

- (void)locationManager:(CLLocationManager *)manager
       didFailWithError:(NSError *)error
{
    NSLog(@"Could not find location: %@", error);
}

- (void)dealloc
{
    if( [locationManager delegate] == self)
        [locationManager setDelegate:nil];
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    /*
     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     */
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
     */
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    /*
     Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
     */
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    /*
     Called when the application is about to terminate.
     Save data if appropriate.
     See also applicationDidEnterBackground:.
     */
}

@end

6
задан Cœur 24 July 2017 в 16:56
поделиться