开发者

EXC_BAD_ACCESS iPhone Dev

开发者 https://www.devze.com 2023-03-10 08:32 出处:网络
I am very new to development in Objective C but have a lot of experience in object orientated development in c# ASP. I\'ve been trying to make a simple iPhone app where a PickerView control is accessi

I am very new to development in Objective C but have a lot of experience in object orientated development in c# ASP. I've been trying to make a simple iPhone app where a PickerView control is accessing a data source.

In my header file (InstaTwitViewController.h) I have declared the following:

@interface InstaTwitViewController : UIViewController
     <UIPickerViewDataSource, UIPickerViewDelegate> {

            NSArray* activities;
            NSArray* feelings;
}

I now try to inititialise my arrays in the viewDidLoad functions in my InstaTwitViewController.m file:

activities = [[NSArray alloc] initWithObjects:@"sleeping", @"eating", @"thinking", nil];
feelings = [[NSArray alloc] initWithObjects:@"psyched", @"sad", @"happy", nil];

but when I run the code on the simulator I get a Thread 1: Program recieved signal "ESC_BAD_ACCESS" error on the first line of code (where I allocate data to the activities array).

I put a break point on the line and it recognises it as an NSArray called activities but says "Invalid Summary" at the end.

Does anyone know why I am getting this error? I have looked at many threads about the ESC_BAD_ACCESS error but none have开发者_开发技巧 seemed to have helped me.


.h

@interface InstaTwitViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate> {
    NSArray* activities;
    NSArray* feelings;
}

@property (nonatomic, retain) NSArray* activities;
@property (nonatomic, retain) NSArray* feelings;

@end

.m

#import "your.h"

@implementation InstaTwitViewController

@synthesize activities, feelings;

- (void)viewDidLoad {
    [super viewDidLoad];

    [self.activities addObject ~ /* Do your code here */];

}

@end

Becareful you should stay on self.~ if you don't want to lose your value. By the way, I am Korean~ ^^;

0

精彩评论

暂无评论...
验证码 换一张
取 消