Objective-c和Xcode奇怪行为

Objective-c和Xcode奇怪行为,objective-c,xcode,Objective C,Xcode,在xcode 4.3.1中,目标是iPad 5.1模拟器 创建单一视图应用程序 使用弧形,不要使用故事板 在ViewController.h中 #import <UIKit/UIKit.h> @interface ViewController : UIViewController { NSObject *anObject; NSObject *anotherObject; } -(void) makeObjects; @end 在AppDe

在xcode 4.3.1中,目标是iPad 5.1模拟器

  • 创建单一视图应用程序
  • 使用弧形,不要使用故事板

  • 在ViewController.h中

    #import <UIKit/UIKit.h>
    
    @interface ViewController : UIViewController
    {
            NSObject *anObject;
            NSObject *anotherObject;
    }
    
    -(void) makeObjects;
    
    @end
    
  • 在AppDelegate.m中添加一行

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
    {
            self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
            // Override point for customization after application launch.
            self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
            self.window.rootViewController = self.viewController;
    
            [self.viewController makeObjects]; // ADD THIS LINE  <--------
    
            [self.window makeKeyAndVisible];
            return YES;
    }
    
  • 跨步断点
  • anObject=0x00000000,设置了另一个对象
您正在使用LLDB调试器吗?目前,它不能在模拟器的IVAR上为您提供正确的值。切换回GDB,您将找到报告的正确值。我在这里发现了这种行为:


是的,我报告了一个错误。我收到了苹果公司的回复,称这是一个已知问题。

您正在使用LLDB调试器吗?目前,它不能在模拟器的IVAR上为您提供正确的值。切换回GDB,您将找到报告的正确值。我在这里发现了这种行为:


是的,我报告了一个错误。苹果公司回复我说这是一个已知的问题。

我喜欢你们对格式的处理。读起来很有趣:)Lol Rob,这是我在Stackoverflow上的第一篇文章。我根本没有格式化文本,只是复制并粘贴:)我喜欢你对格式化所做的。读起来很有趣:)Lol Rob,这是我在Stackoverflow上的第一篇文章。我根本没有格式化文本,只是简单地复制和粘贴:)谢谢Aaron,我使用的是LLDB。没问题@AlessandroCalciati,你介意接受我的答案吗?谢谢:)谢谢Aaron,我在用LLDB。没问题@AlessandroCalciati,你介意接受我的回答吗?谢谢:)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
        self.window.rootViewController = self.viewController;

        [self.viewController makeObjects]; // ADD THIS LINE  <--------

        [self.window makeKeyAndVisible];
        return YES;
}
anObject = [[NSObject alloc] init];