kunal-iPhone Developer
kunal-iPhone Developer

Reputation: 193

Threading in iphone

I m using NSoperationQueue for load song from server.

This code execute when click on diff-diff buttons.

NSOperationQueue *queue;

NSInvocationOperation *operation = [[NSInvocationOperation alloc]

initWithTarget:self selector:@selector(loadImage)object:nil];

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

[queue addOperation:operation]; 

Problem is that when user click ie.Rama.aac then loading continue in this duration if he click krishna.aac then this process also goes into that queue.and conflicting is there.

user is finally requesting for krishna but in result first download rama.aac then krishna.aac.

I m using [queue cancelAllOperations] but it not works.

How i solve this?

Upvotes: 0

Views: 248

Answers (2)

ynnckcmprnl
ynnckcmprnl

Reputation: 4352

If I'm not mistaken using NSOperations to load data from a network is not advised. You should use the asynchronous loading NSURLConnection provides.

Upvotes: 1

TheBlack
TheBlack

Reputation: 1245

Implement your own NSOperation subclass. NSOperation has isCancelled property set when cancelAllOperations is called on the queue.

Upvotes: 1

Related Questions