0

I am trying to make a Wolfram | Alpha searcher in XCode 5. Using the API I need to access the pods (the first level of NSCollectionView) and the subpods (The nested NSCollectionView). I have a pod class (properties: podTitle [NSString] and subpods [NSMutableArray of Subpods]) and a subpod class (properties: subPodTitle [NSString] and image [NSImage]). I have two NSArrayControllers, one linked to the viewcontroller's array of pods, and one to each to the represented object's subpods. pods and subpods Sample output: http://products.wolframalpha.com/api/explorer.html When I perform a query I get the following error: [_NSClipViewOverhangView delegate]: unrecognized selector sent to instance 0x600000122c60' on the following line [podArrayController rearrangeObjects]

- (IBAction)waSearch:(NSSearchField *)sender {
[self.wa.pods removeAllObjects];
self.wa.input = [sender stringValue];
self.wa.url = [NSString stringWithFormat:@"http://api.wolframalpha.com/v2/query?appid=%@&input=%@&format=html,image,plaintext,sound", appID, self.wa.input];
NSLog(@"%@", self.wa.input);
dispatch_queue_t fetchQueue = dispatch_queue_create("fetch xml", NULL);
dispatch_async(fetchQueue, ^{[self.wa performQuerywithURL:self.wa.url];
    dispatch_async(dispatch_get_main_queue(), ^{
        [podArrayControler rearrangeObjects];
        [subpodArrayControler rearrangeObjects];
    });
});

}

Method used to add pods

- (NSMutableArray *)performQuerywithURL:(NSString *)url {
url = [url stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];

NSXMLDocument *xml  = [[NSXMLDocument alloc] initWithContentsOfURL:[NSURL URLWithString:url] options:(NSXMLNodePreserveWhitespace|NSXMLNodePreserveCDATA) error:nil];
//NSArray *img_xmlnodes = [xml nodesForXPath:@".//subpod/img" error:nil];
NSArray *pod_xmlnodes = [xml nodesForXPath:@".//pod" error:nil];

for (NSXMLNode *waPod in pod_xmlnodes) {
    if ([waPod kind] == NSXMLElementKind) {
        Pod* pod = [[Pod alloc] init];
        for (NSXMLNode* podAttribute in [((NSXMLElement *) waPod) attributes]) {
            if ([[podAttribute name] isEqualToString:@"title"]) {
                pod.podTitle = [podAttribute stringValue];
            }
        }
        NSArray* pod_children = [waPod nodesForXPath:@".//subpod" error:nil];

        for (NSXMLNode *child in pod_children) {
            if ([child kind] == NSXMLElementKind) {
                Subpod *subPod = [[Subpod alloc] init];
                subPod.subPodTitle = [[((NSXMLElement *) child)  attributes][0] stringValue];
                NSLog(@"%@%@", subPod.subPodTitle, [[([((NSXMLElement *) child)  children][1]) attributes][0] stringValue]);

                subPod.image = [[NSImage alloc] initWithContentsOfURL:[NSURL URLWithString:[[([((NSXMLElement *) child)  children][1]) attributes][0] stringValue]]];
                [pod.subpods addObject:subPod];

            }
        }
        [self.pods addObject:pod];
    }

}
return self.pods;
}

Full error:

-[_NSClipViewOverhangView delegate]: unrecognized selector sent to instance 0x600000124060
objc[10578]: EXCEPTIONS: throwing 0x600000127058 (object 0x60000024c3f0, a NSException)
objc[10578]: EXCEPTIONS: searching through frame [ip=0x7fff8ce5570e sp=0x7fff5fbfdcf0] for exception 0x600000127038
objc[10578]: EXCEPTIONS: catch(NSException)
objc[10578]: EXCEPTIONS: unwinding through frame [ip=0x7fff8ce5570e sp=0x7fff5fbfdcf0] for exception 0x600000127038
objc[10578]: EXCEPTIONS: handling exception 0x600000127038 at 0x7fff8ce5572d
objc[10578]: EXCEPTIONS: throwing 0x600000126fb8 (object 0x60000024c3f0, a NSException)
objc[10578]: EXCEPTIONS: searching through frame [ip=0x7fff8ce55741 sp=0x7fff5fbfdcf0] for exception 0x600000126f98
objc[10578]: EXCEPTIONS: searching through frame [ip=0x7fff8d3f02ac sp=0x7fff5fbfdff0] for exception 0x600000126f98
objc[10578]: EXCEPTIONS: unwinding through frame [ip=0x7fff8ce55741 sp=0x7fff5fbfdcf0] for exception 0x600000126f98
objc[10578]: EXCEPTIONS: finishing handler
objc[10578]: EXCEPTIONS: releasing completed exception 0x600000127058 (object 0x60000024c3f0, a NSException)
objc[10578]: EXCEPTIONS: unwinding through frame [ip=0x7fff8ce5575e sp=0x7fff5fbfdcf0] for exception 0x600000126f98
objc[10578]: EXCEPTIONS: unwinding through frame [ip=0x7fff8d3f02ac sp=0x7fff5fbfdff0] for exception 0x600000126f98
objc[10578]: EXCEPTIONS: handling exception 0x600000126f98 at 0x7fff8d3f02bc
objc[10578]: EXCEPTIONS: terminating
objc[10578]: EXCEPTIONS: searching through frame [ip=0x7fff94a812d4 sp=0x7fff5fbfdf90] for exception 0x600000126f98
objc[10578]: EXCEPTIONS: catch(id)
objc[10578]: EXCEPTIONS: unwinding through frame [ip=0x7fff94a812d4 sp=0x7fff5fbfdf90] for exception 0x600000126f98
objc[10578]: EXCEPTIONS: handling exception 0x600000126f98 at 0x7fff94a812f3
2013-11-20 16:51:24.000 AAU[10578:303] An uncaught exception was raised
2013-11-20 16:51:24.010 AAU[10578:303] -[_NSClipViewOverhangView delegate]: unrecognized selector sent to instance 0x600000124060
2013-11-20 16:51:24.010 AAU[10578:303] (
    0   CoreFoundation                      0x00007fff8c00141c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff94a80e75 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8c0042ed -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00007fff8bf5f5b2 ___forwarding___ + 1010
    4   CoreFoundation                      0x00007fff8bf5f138 _CF_forwarding_prep_0 + 120
    5   AppKit                              0x00007fff8ce77e56 -[NSCollectionViewItem _copyConnectionsOfObject:prototypeItem:toObject:item:] + 313
    6   AppKit                              0x00007fff8ce78058 -[NSCollectionViewItem _copyConnectionsOfObject:prototypeItem:toObject:item:] + 827
    7   AppKit                              0x00007fff8ce78058 -[NSCollectionViewItem _copyConnectionsOfObject:prototypeItem:toObject:item:] + 827
    8   AppKit                              0x00007fff8ce78058 -[NSCollectionViewItem _copyConnectionsOfObject:prototypeItem:toObject:item:] + 827
    9   AppKit                              0x00007fff8ce780d2 -[NSCollectionViewItem _copyConnectionsToItem:] + 95
    10  AppKit                              0x00007fff8ce77cce -[NSCollectionViewItem copyWithZone:] + 516
    11  AppKit                              0x00007fff8ce79cde -[NSCollectionView newItemForRepresentedObject:] + 68
    12  AppKit                              0x00007fff8ce80c01 -[NSCollectionView _getItemsToDisplay] + 1198
    13  AppKit                              0x00007fff8ce793ca -[NSCollectionView setContent:] + 214
    14  AppKit                              0x00007fff8ce5570f -[NSCollectionViewBinder _updateContent] + 91
    15  AppKit                              0x00007fff8ce557b3 -[NSCollectionViewBinder _observeValueForKeyPath:ofObject:context:] + 84
    16  Foundation                          0x00007fff91238c18 NSKeyValueNotifyObserver + 387
    17  Foundation                          0x00007fff91275e71 -[NSObject(NSKeyValueObservingPrivate) _notifyObserversForKeyPath:change:] + 1115
    18  AppKit                              0x00007fff8c6c5c48 -[NSController _notifyObserversForKeyPath:change:] + 209
    19  AppKit                              0x00007fff8c7f76a7 -[NSArrayController didChangeValuesForArrangedKeys:objectKeys:indexKeys:] + 53
    20  AAU                                 0x0000000100005395 __40-[AOUControllerViewController waSearch:]_block_invoke_2 + 53
    21  libdispatch.dylib                   0x00007fff8d3f31d7 _dispatch_call_block_and_release + 12
    22  libdispatch.dylib                   0x00007fff8d3f02ad _dispatch_client_callout + 8
    23  libdispatch.dylib                   0x00007fff8d3f7f03 _dispatch_main_queue_callback_4CF + 333
    24  CoreFoundation                      0x00007fff8bf68839 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    25  CoreFoundation                      0x00007fff8bf23b14 __CFRunLoopRun + 1636
    26  CoreFoundation                      0x00007fff8bf23275 CFRunLoopRunSpecific + 309
    27  HIToolbox                           0x00007fff92367f0d RunCurrentEventLoopInMode + 226
    28  HIToolbox                           0x00007fff92367cb7 ReceiveNextEventCommon + 479
    29  HIToolbox                           0x00007fff92367abc _BlockUntilNextEventMatchingListInModeWithFilter + 65
    30  AppKit                              0x00007fff8c63d28e _DPSNextEvent + 1434
    31  AppKit                              0x00007fff8c63c8db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
    32  AppKit                              0x00007fff8c6309cc -[NSApplication run] + 553
    33  AppKit                              0x00007fff8c61b803 NSApplicationMain + 940
    34  AAU                                 0x0000000100001372 main + 34
    35  libdyld.dylib                       0x00007fff95af75fd start + 1
)
2013-11-20 16:51:24.012 AAU[10578:303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_NSClipViewOverhangView delegate]: unrecognized selector sent to instance 0x600000124060'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff8c00141c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff94a80e75 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8c0042ed -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00007fff8bf5f5b2 ___forwarding___ + 1010
    4   CoreFoundation                      0x00007fff8bf5f138 _CF_forwarding_prep_0 + 120
    5   AppKit                              0x00007fff8ce77e56 -[NSCollectionViewItem _copyConnectionsOfObject:prototypeItem:toObject:item:] + 313
    6   AppKit                              0x00007fff8ce78058 -[NSCollectionViewItem _copyConnectionsOfObject:prototypeItem:toObject:item:] + 827
    7   AppKit                              0x00007fff8ce78058 -[NSCollectionViewItem _copyConnectionsOfObject:prototypeItem:toObject:item:] + 827
    8   AppKit                              0x00007fff8ce78058 -[NSCollectionViewItem _copyConnectionsOfObject:prototypeItem:toObject:item:] + 827
    9   AppKit                              0x00007fff8ce780d2 -[NSCollectionViewItem _copyConnectionsToItem:] + 95
    10  AppKit                              0x00007fff8ce77cce -[NSCollectionViewItem copyWithZone:] + 516
    11  AppKit                              0x00007fff8ce79cde -[NSCollectionView newItemForRepresentedObject:] + 68
    12  AppKit                              0x00007fff8ce80c01 -[NSCollectionView _getItemsToDisplay] + 1198
    13  AppKit                              0x00007fff8ce793ca -[NSCollectionView setContent:] + 214
    14  AppKit                              0x00007fff8ce5570f -[NSCollectionViewBinder _updateContent] + 91
    15  AppKit                              0x00007fff8ce557b3 -[NSCollectionViewBinder _observeValueForKeyPath:ofObject:context:] + 84
    16  Foundation                          0x00007fff91238c18 NSKeyValueNotifyObserver + 387
    17  Foundation                          0x00007fff91275e71 -[NSObject(NSKeyValueObservingPrivate) _notifyObserversForKeyPath:change:] + 1115
    18  AppKit                              0x00007fff8c6c5c48 -[NSController _notifyObserversForKeyPath:change:] + 209
    19  AppKit                              0x00007fff8c7f76a7 -[NSArrayController didChangeValuesForArrangedKeys:objectKeys:indexKeys:] + 53
    20  AAU                                 0x0000000100005395 __40-[AOUControllerViewController waSearch:]_block_invoke_2 + 53
    21  libdispatch.dylib                   0x00007fff8d3f31d7 _dispatch_call_block_and_release + 12
    22  libdispatch.dylib                   0x00007fff8d3f02ad _dispatch_client_callout + 8
    23  libdispatch.dylib                   0x00007fff8d3f7f03 _dispatch_main_queue_callback_4CF + 333
    24  CoreFoundation                      0x00007fff8bf68839 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    25  CoreFoundation                      0x00007fff8bf23b14 __CFRunLoopRun + 1636
    26  CoreFoundation                      0x00007fff8bf23275 CFRunLoopRunSpecific + 309
    27  HIToolbox                           0x00007fff92367f0d RunCurrentEventLoopInMode + 226
    28  HIToolbox                           0x00007fff92367cb7 ReceiveNextEventCommon + 479
    29  HIToolbox                           0x00007fff92367abc _BlockUntilNextEventMatchingListInModeWithFilter + 65
    30  AppKit                              0x00007fff8c63d28e _DPSNextEvent + 1434
    31  AppKit                              0x00007fff8c63c8db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
    32  AppKit                              0x00007fff8c6309cc -[NSApplication run] + 553
    33  AppKit                              0x00007fff8c61b803 NSApplicationMain + 940
    34  AAU                                 0x0000000100001372 main + 34
    35  libdyld.dylib                       0x00007fff95af75fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Nothing I have done seems to helped get any closer to correcting the bug, let alone why and how it is happening

Python Spoils You
  • 374
  • 1
  • 2
  • 12
  • You should add an exception breakpoint. At some point, some code calls `delegate` on an NSClipView (which doesn't have a `delegate` property.) The exception breakpoint will let you view the stack trace so you can figure out where it's coming from. An alternative explanation: an NSClipView is being passed into / returned from a method, where a different object type is expected. – Aaron Brager Nov 20 '13 at 21:51
  • @AaronBrager I did add one (I just was fiddling around), I do know where its coming from, from the `[podArrayController rearrangeObjects]`, however, I do not know why it is causing the error, or how to fix it. – Python Spoils You Nov 20 '13 at 21:55
  • 1
    How do you add objects to `podArrayController`? What types of objects are in it? – Aaron Brager Nov 20 '13 at 22:01
  • @AaronBrager In my controller class, I have an Instance of my "waQuery" (called `wa`) (Wolfram | Alpha query) in which I have a pods property, so I pull it from that, `self.wa.pods` which I add to using the a method I will add by editing the question. The NSArray controller `podArrayController` is bound to to the mutable array, `self.wa.pods` The array contains `Pod` Objects – Python Spoils You Nov 20 '13 at 22:05
  • The other array, `subPodArrayController` is bound to the `arrangedObjects` with model key path `subpods` of `podArrayController` – Python Spoils You Nov 20 '13 at 22:10
  • 1
    You know, of course that the method means that the `delegate` method is being called on a `NSClipViewOverhangView` object. Most often this is because the wrong object has been assigned to a pointer somewhere. Likely the wrong object has crept into your arrangedObjects list or some such. – Hot Licks Nov 20 '13 at 22:48
  • @HotLicks That's what I thought, However, I cannot seem to find how that is possible. – Python Spoils You Nov 20 '13 at 23:35
  • @HotLicks I also logged the `[podArrayController arrangedObjects]` and they were all of type `Pod` – Python Spoils You Nov 20 '13 at 23:42
  • @HotLicks However What I did find was that no matter how I tried to bind the `NSArrayController subPodArrayController` it always was empty. (`subpods` is `NSMutableArray of `Subpods` which is a property of the pod class, so every `pod` in the `podArrayController` has an array of `subpods`. How could I bind this to an `NSArrayController`? – Python Spoils You Nov 21 '13 at 00:21
  • Can't help you with NSArrayController -- never used it. I would suggest, though, that you see if you can figure out where an NSClipViewOverhangView (something I've never even heard of) is being used, and that may give you a hint as to how the wrong pointer is getting in the wrong place. – Hot Licks Nov 21 '13 at 00:38
  • 1
    Of course, remember that another possibility is that one of your objects was deleted without removing its pointer from the arrangedObjects list or wherever, and then the NSClipViewOverhangView got allocated in its place. – Hot Licks Nov 21 '13 at 00:40
  • @HotLicks When I googled it I got no relevant responses, I also looked it up in the Apple's Documentation, and found nothing :( – Python Spoils You Nov 21 '13 at 00:40
  • @HotLicks Do you know how the object could have been removed? – Python Spoils You Nov 21 '13 at 00:51
  • The object could have been removed by screwing up reference counting somehow. – Hot Licks Nov 21 '13 at 01:07
  • 1
    Based on a quick Google, I suspect that NSClipViewOverhangView is an internal class used by NSClipView, which is normally only used inside an NSScrollView. This would increase the likelihood that the deallocated object scenario is the right one. – Hot Licks Nov 21 '13 at 01:10
  • @HotLicks You are very likely to be right, the only thing I can think if the fact that NSCollection views are views that are within scrollviews… I do not know how it could be getting in anywhere in my arrays or controllers thereof… – Python Spoils You Nov 21 '13 at 01:21
  • All you need is an object you're creating that has a `delegate` property, then accidentally have that get deleted while still addressable somehow. Independently, the scroll view creates the NSClip tingie, and so an attempt by your code to reference the original object results in the failure. – Hot Licks Nov 21 '13 at 01:43
  • @HotLicks I can't find a situation where that would happen anywhere in my code… hmm… – Python Spoils You Nov 21 '13 at 01:49
  • You can't find a situation anywhere in your code where you have a (retain) bug? – Hot Licks Nov 21 '13 at 02:48
  • No, I was unable to find any – Python Spoils You Nov 21 '13 at 03:29

0 Answers0