1

I was developing an app, at some stage this error came out:

-[__NSArrayM popObjectForKey:]: unrecognized selector sent to instance

I've undone the latest edits to see what was wrong...but the error was still there. So I've undone even more edits, but the error was still there.

Tried to delete and add back the framework where I thought the error could come from, error still there. (it's KinveyKit framework)

Tried to substitute the line of code where the app would throw the error with another one that was surely working: even that one was throwing the error.

I downloaded an older Git of the app (that was definitely working a few days ago) on a different folder, run that and: same error.

Uninstalled and reinstalled Xcode: error still there.

But: if I run other apps with similar code, nothing goes wrong. Does anybody have any idea?

I post here the code, that throws me the error, just to give you an idea...but I don't think there's anything wrong in the code since it's always been working before.

.h

@property (strong, nonatomic) KCSAppdataStore *store;

.m

- (void)viewDidLoad
{
  ...

  _store = [KCSAppdataStore storeWithOptions:@{ KCSStoreKeyCollectionName : @"AnEntity",
                                                KCSStoreKeyCollectionTemplateClass : [AnEntity class]}];

  [_store queryWithQuery:[KCSQuery query]
          withCompletionBlock:^(NSArray *objectsOrNil1, NSError *errorOrNil) { ... }];

  ...
}
4

2 回答 2

1

酷——讽刺

我花了一个下午从一个新项目重建应用程序,复制粘贴代码......现在我再次打开旧的,试图运行它只是......只是再试一次,知道它会崩溃,因为我没有t改变一个词,它已经在我今天早上早些时候尝试的每隔一段时间就崩溃了,而且....惊喜:再次运行。没有错误。

-.-'' 解决我的问题呢?不知道。仍然认为这是一些缓存问题最终在一天中得到解决,但在我试图解决它的时候却没有。

如果有人有类似的经历或有更多的想法,请随时添加一些东西,总是为下次发生类似的事情做好准备。

于 2013-10-09T23:03:06.150 回答
1

我有一个类似的问题,似乎是由KCSUser写入钥匙串的损坏对象引起的。该popObjectForKey方法似乎在您调用任何时候都会被调用[KCSUser activeUser]。我可以通过在application DidFinishLaunchingWithOptions:. [KCSUser activeUser]在以下代码有机会运行之前,请确保您没有在任何时候调用。

NSArray *secItemClasses = @[(__bridge id)kSecClassGenericPassword,
                            (__bridge id)kSecClassInternetPassword,
                            (__bridge id)kSecClassCertificate,
                            (__bridge id)kSecClassKey,
                            (__bridge id)kSecClassIdentity];
for (id secItemClass in secItemClasses) {
    NSDictionary *spec = @{(__bridge id)kSecClass: secItemClass};
    SecItemDelete((__bridge CFDictionaryRef)spec);
}

这似乎清除/重置钥匙串。运行一次后,将其删除,您的应用程序应该可以正常运行。

于 2013-12-16T22:48:17.810 回答