Unrecognized Selector Sent to Instance [NSCFString subarrayWithRange:]

十年热恋 提交于 2019-12-03 13:32:46

These kinds of errors are usually memory-management-related. Essentially, you're sending a message to an address that's now occupied by some other object because the previous occupant has unexpectedly disappeared. Since that address space could be occupied by anything, you just happen to be asking an NSCFString something to which it doesn't respond.

If you pause the debugger right after you create the temp array, what do you see assigned to temp? I'm guessing something's not quite right with whatever -keysArray returns. You might want to double-check how the memory is handled in whatever that's supposed to return. By the name, I suppose your app delegate has an array called "keysArray" as an instance variable. Perhaps that's not being properly retained when it's created or assigned?

Jeff

So I had this one. I did something stupid. I assigned the UITextView to a string instead of it's text property. ie:

myObj.txtbxThing = [NSString stringWithFormat:@"%@", stuffString];

instead of:

myObj.txtbxThing.text = [NSString stringWithFormat:@"%@", stuffString];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!