Reputation: 480
I've subclassed NSOperation and - (void) main is ok, (since it worked before using NSOperation), I've also stepped through the init method and the variables are initialized correctly. All tough after the -(id) initWithSampleBuffer: is done and I'm trying to add the uploadOperation to the NSOperationQueue:
UploadOperation *ulOp = [[UploadOperation alloc] initWithSampleBuffer:sampleBuffer];
[queue addOperation:ulOp]; //here i get exc_bad_access
[ulOp release];
I get exc_bad_access. I've tried breakpoints and I can see that queue exists and so do ulOp. I can't figure out what I'm doing wrong, since to my understanding exc_bad_access occurs when you're trying to pass a "message" to something that is already deallocated, and clearly, none of them are.
- (id)initWithSampleBuffer:(CMSampleBufferRef) aSampleBuffer {
sampleBuffer = aSampleBuffer;
VideoStreamViewController *vc = [VideoStreamViewController shared];
ul = [[Uploader alloc] initWithURL:[NSURL alloc] filePath:@"" delegate:vc doneSelector:@selector(didFinishUpload:) errorSelector:@selector(uploadFailed:)];
return self;
}
however the Uploader stuff, isn't the problem (i've removed it and still get the same result). and from what i can se there no problem with the CMSampleBuffer object, it is initialized!
init of queue:
in .h:
NSOperationQueue *queue;
@property (nonatomic, retain) NSOperationQueue *queue;
in .m:
@synthesize queue;
self.queue = [[NSOperationQueue alloc] init];
[queue setMaxConcurrentOperationCount:1];
Upvotes: 0
Views: 788
Reputation: 38475
You're not calling [super init]
inside your constructor?
Assuming you're subclassing NSOperation (or NSObject etc...), you probably should!
Upvotes: 5