0

I have a ARC enabled Mac project with a non-ARC enabled framework, all compiles fine but once run the non-ARC framework displays a form, however when you click a button, a error is thrown like...

2012-11-10 23:32:11.191 TestApp[20691:303] -[__NSCFType next:]: unrecognized selector sent to instance 0x101c13070
2012-11-10 23:32:11.193 TestApp[20691:303] -[__NSCFType next:]: unrecognized selector sent to instance 0x101c13070
2012-11-10 23:32:11.198 TestApp20691:303 doesNotRecognizeSelector:] + 186
3 CoreFoundation 0x00007fff8e63a5ce forwarding + 414
4 CoreFoundation 0x00007fff8e63a3b8 _CF_forwarding_prep_0 + 232
5 AppKit 0x00007fff8ff78a59 -[NSApplication sendAction:to:from:] + 342
6 AppKit 0x00007fff8ff788b7 -[NSControl sendAction:to:] + 85
7 AppKit 0x00007fff8ff787eb -[NSCell _sendActionFrom:] + 138
8 AppKit 0x00007fff8ff76cd3 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1855
9 AppKit 0x00007fff8ff76521 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
10 AppKit 0x00007fff8ff75c9c -[NSControl mouseDown:] + 820
11 AppKit 0x00007fff8ff6d60e -[NSWindow sendEvent:] + 6853
12 AppKit 0x00007fff8ff69744 -[NSApplication sendEvent:] + 5761
13 AppKit 0x00007fff8fe7f2fa -[NSApplication run] + 636
14 AppKit 0x00007fff8fe23cb6 NSApplicationMain + 869
15 AppSim 0x00000001000026f2 main + 34
16 libdyld.dylib 0x00007fff97c6c7e1 start + 0
17 ??? 0x0000000000000003 0x0 + 3

Converting the main project to non-ARC the problem goes... what is causing the problem, and how do I get around it?

I rather not convert my existing project to use non-ARC...

Steps to reproduce problem...

Download "Sample Project for OS X Lion, ~250 KB" from

https://github.com/eternalstorms/ESSVideoShare-for-OS-X-Lion

Convert the main project to ARC, point the line starting with ... [yt uploadVideoAtURL:[NSURL fileURLWithPath to any mov file you have, then run.

Clicking cancel or sign-in will cause the error...

Equinox2000
  • 576
  • 6
  • 17
  • plz add your console output to show us WHAT selector it doesnt recognize – Daij-Djan Nov 11 '12 at 20:20
  • That is my entire console output, i do know that putting a break point on a (IBAction)next:(id)sender never gets called and error occurs when button clicked, and as mentioned above when using non-ARC the action is fired without error – Equinox2000 Nov 11 '12 at 20:25
  • ah, something is not retaining the click target and so it gets deallocated. Non-ARC code converted to arc but there are many cases where it doesnt work -- @SlyRaskal's comment is important for you :) – Daij-Djan Nov 11 '12 at 20:29
  • In addition, this question has nothing to do with Xcode at all. Removed false tag. –  Nov 11 '12 at 20:34
  • The framework is fully non-ARC and main project is completely ARC so don't think its a case of disabling ARC for relevant classes as not dragged any files from the framework into my project i.e i'm only linking to the framework. – Equinox2000 Nov 11 '12 at 20:35

2 Answers2

2

Your sample code has a memory leak:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
    ESSYouTube *yt = [[ESSYouTube alloc] initWithDelegate:self
                                             developerKey:@""];
    [yt uploadVideoAtURL:[NSURL fileURLWithPath:@"/path/to/mov"]];
}

yt is never released.

When you plug that leak, either by adding a release or by converting to ARC, you will get the crash because the ESSYouTube and ESSYouTubeWindowController instances have been deallocated while the UI is still on screen.

The sample code needs to be fixed, and ESSYouTube should either retain itself as long its UI is on screen, or it should tear down its UI upon deallocation.

Darren
  • 25,520
  • 5
  • 61
  • 71
  • Great thanks for your help, i noticed as a quick test removing the autorelease from self._ytWinCtr = [[[ESSYouTubeWindowController alloc] initWithDelegate:self videoURL:url] autorelease]; fixed the crash... now to refactor the code :) – Equinox2000 Nov 11 '12 at 21:43
1

You can have a project that has ARC and non-ARC assets. If you haven't already, I would set any classes that are not ARC enabled to not compile using ARC. Refer to here: How can I disable ARC for a single file in a project?

Community
  • 1
  • 1
Anil
  • 2,539
  • 6
  • 33
  • 42
  • Dont think thats it, as mentioned above "The framework is fully non-ARC and main project is completely ARC so don't think its a case of disabling ARC for relevant classes as not dragged any files from the framework into my project i.e i'm only linking to the framework." – Equinox2000 Nov 11 '12 at 20:35
  • He mentions that the non-ARC code is in a static library. There are no individual class files to set to compile without ARC at that point, because they have already been compiled. (And presumably it was done without ARC.) – Peter Hosey Nov 11 '12 at 22:19