1

私の.hファイルには次のものがあります:

    #import <UIKit/UIKit.h>


@interface untitled : UIViewController 
{
    NSMutableString * sResults;
}

@property (nonatomic,retain) NSMutableString * sResults;

@end

私の .mi には次のものがあります。

#import "untitled.h"


@implementation untitled

@synthesize sResults;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    sResults = [[NSMutableString alloc] initWithString:@"Hello"];
    [sResults appendString:@" World"];
}

@end

sResults をチェックするたびに、「範囲外」と表示されます。何が間違っていますか?

4

1 に答える 1

2

これを試して:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.sResults = [NSMutableString stringWithString:@"Hello"]; //retained in synthesized setter
    [self.sResults appendString:@" World"];
}
于 2010-11-07T22:45:27.077 に答える