Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RACAbleSelf syntax changed? #14

Closed
tonyarnold opened this issue Jul 9, 2012 · 6 comments
Closed

RACAbleSelf syntax changed? #14

tonyarnold opened this issue Jul 9, 2012 · 6 comments

Comments

@tonyarnold
Copy link
Contributor

I'm having issues with RACAbleSelf and RACAbleSelfWithStart, whereby my class has a public NSURL property urlToLoad:

@property(nonatomic, strong) NSURL *urlToLoad;

However when I call the following (as shown in all the samples):

[[RACAbleSelfWithStart(self.urlToLoad) distinctUntilChanged] subscribeNext:^(NSURL * newURL) {…}];

I get the following error:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MyViewController 0x8bb33a0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key self.urlToLoad.'

I've tried changing it to just:

[[RACAbleSelfWithStart(urlToLoad) distinctUntilChanged] subscribeNext:^(NSURL * newURL) {…}];

This works, but my app complains about observation info being leaked whenever the view controller is deallocated. Breaking on NSKVODeallocateBreak doesn't yield anything useful, but I assume that the NSURL instance is somehow outliving the view controller. Here's the error

An instance 0xf47de20 of class MyViewController was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info:
<NSKeyValueObservationInfo 0x13e6a190> (
<NSKeyValueObservance 0x13e6a150: Observer: 0x13e6a0c0, Key path: urlToLoad, Options: <New: NO, Old: NO, Prior: NO> Context: 0x19e6a0, Property: 0x13e6a1d0>
)

Am I missing something really obvious here? The project uses ARC.

@tonyarnold
Copy link
Contributor Author

OK, after a fair bit of mucking about it looks like the RACAbleSelfWithStart() macro is broken for me. It works if I manually setup the call like so:

[[[RACAbleSelf(self.urlToLoad) startWith:self.urlToLoad] distinctUntilChanged] subscribeNext:^(NSURL * newURL) {…}];

It looks like "self." is being prepended to the key path, and for me at least this is causing issues.

@joshaber
Copy link
Member

joshaber commented Jul 9, 2012

Thanks for doing the detective work on this @tonyarnold! Does that also solve your NSKVODeallocate problem?

I'd been thinking about removing RACAbleWithStart since it seemed a bit overly specific. This is the kick in the pants I needed to actually do it.

@joshaber joshaber closed this as completed Jul 9, 2012
@tonyarnold
Copy link
Contributor Author

Sadly, no. I'm still looking into that. RAC swizzles dealloc, right? I'm now seeing some messed up crashes where dealloc is called from different classes as various RAC'd objects deallocate! My luck: it is missing!

@joshaber
Copy link
Member

Interesting... I'd be interested to look into it if you can share the code at all. I'm definitely starting to wonder if there's a RAC bug there.

@tonyarnold
Copy link
Contributor Author

Here's a test project demonstrating the RACAbleSelfWithStart issue: http://cl.ly/2q1c3r1U3v233Z2C2u1S

@tonyarnold
Copy link
Contributor Author

Yeah, something is quite wrong here: my UIApplicationDelegate was just deallocated when one of my view controllers using RAC was dismissed.

What do you need to chase this down? It's happening in a private client project, so I can't share the source publicly but I'd be happy to give you as much information as you need short of that (or to share the project privately).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants