开发者

exc_bad_acccess when adding to NSOperationQueue

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 (nonatomi开发者_运维百科c, retain) NSOperationQueue *queue;

in .m:

@synthesize queue;
self.queue = [[NSOperationQueue alloc] init];
[queue setMaxConcurrentOperationCount:1];


You're not calling [super init] inside your constructor?

Assuming you're subclassing NSOperation (or NSObject etc...), you probably should!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜