I've been trying to figure this out but I can't figure out what I'm doing wrong.
I wro开发者_如何学运维te a class and whenever I try to initialize it, I get a EXC_BAD_ACCESS error. I can't even step into the initialization.
Anyone have any idea what I'm doing wrong?
User *myUser = [myUser init];
.h file:
#import <Foundation/Foundation.h>
@interface User : NSObject {
long rowId;
NSString *email;
NSString *password;
NSString *fileVersion;
}
@property long rowId;
@property (assign) NSString *email;
@property (assign) NSString *password;
@property (assign) NSString *fileVersion;
@end
.m file
#import "User.h"
@implementation User
@synthesize rowId, email, password, fileVersion;
-(id)init {
self = [super init];
return self;
}
@end
You have to actually allocate the object:
User *myUser = [[User alloc] init];
Don't forget to release
it when you're done using it.
精彩评论