• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Adding an observer to an NSOperation crashes my app.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding an observer to an NSOperation crashes my app.


  • Subject: Re: Adding an observer to an NSOperation crashes my app.
  • From: Mike Abdullah <email@hidden>
  • Date: Sat, 14 Jan 2012 12:38:21 +0000

Your code snippet got mangled making it very hard for me to read. Please can we have a full backtrace for the crash. Is there anything interesting in the console? Have you tried running with zombies enabled?

On 14 Jan 2012, at 07:30, G S wrote:

> Hi all.  Working on an iPhone app and encountered a stumper.
>
> I have various kinds of operations (derived from NSOperation) to do async
> queries over the Internet. As is the norm, I determine when they're
> finished by observing their isFinished property, and getting the results in
> observeValueForKeyPath (which as you may know is called in a secondary
> thread).  This works great all over my app.  Except...
>
> When one particular type of operation finishes, I want to create a
> follow-up type of operation using info from the first. But when I do so,
> calling addObserver on the operation crashes my app with a bad access.
> Since observeValueForKeyPath is called in a secondary thread, I tried
> creating the follow-up operation and setting the observer on the main
> thread. Didn't help. This is being done in observeValueForKeyPath:
>
> *GetMessagesOperation* msgOp = [[GetMessagesOperation alloc]
>> initWithUserID:_user.getID() sinceLast:true              includeSystem:true
>> includeUser:false skipRows:0 maxCount:50 DBManager:_pDatabaseMgr];
>> *
>
>
>
>> *[msgOp addObserver:self forKeyPath:@"isFinished" options:0
>> context:getMessageContext];
>> *
>
>
>
>> *[_operationQueue addOperation:msgOp];
>> *
>
>
>
>> *[msgOp release];*
>
>
> The context is a void* to a string; I use the same syntax for many other
> operations that work fine. Here's how the contexts are defined:
>
> *static void* systemInfoContext = (void*)@"sys";
> static void* validateUserContext = (void*)@"user";
> static void* getMessageContext = (void*)@"msg";*
>
> It crashes instantly on that addObserver call.  Anybody have a guess here?
> Thanks!
>
> Gavin
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Adding an observer to an NSOperation crashes my app.
      • From: G S <email@hidden>
References: 
 >Adding an observer to an NSOperation crashes my app. (From: G S <email@hidden>)

  • Prev by Date: MAX parsing (Re: TBXML question)
  • Next by Date: Re: Is slowing down bindings updates possible?
  • Previous by thread: Adding an observer to an NSOperation crashes my app.
  • Next by thread: Re: Adding an observer to an NSOperation crashes my app.
  • Index(es):
    • Date
    • Thread