tags:

views:

403

answers:

2

Hi,
I have a working iPhone project that I'm trying to rearrange on different projects in order to reuse code.
I opened a new project that contains all my utility classes and referenced them from another project. One of the utilities I use is the JSON framework.
The project complies OK but at run-time it throws an exception when I'm trying to call the JSONValue method of the string object the framework extend using categories.
The exception is [NSObject doesNotRecognizeSelector]

Anyone knows a solution for that problem? Should I change the project preferences?

Thanks!

+1  A: 

Sounds like you need to explicitly add the JSON framework to the current project's frameworks. When you import class files you don't automatically import everything those classes import.

TechZen
That doesn't make any sense. Three20 library also extends nsobjects and you only reference it's library so why should I copy the same files over and over again ?
lnetanel
It has nothing to do with extending NSObjects it has to do with where Xcode looks for source files. Just because you references a file that uses a framework in Project A doesn't mean that Project B automatically imports the frameworks when you add that file to it. When you add a framework, you usually don't copy the files, that is what makes frameworks different from ordinary source files. Just add the JSON project to the new project and if that solves the problem I'm right.
TechZen
The JSON framework is actually a couple of source files it's not an actual framework so copying them to my project for sure will solve my problem because this is what I did in the first place, the thing is that I don't want to copy separate source files for every project I use those files, I want an Utility project that I can maintain and reference from each project that want to use those utilities files, JSON is only one of those utilities. Is this even possible?
lnetanel
Okay, I was thrown off by your use of the word framework. Frameworks are special types of files in objective-c. They even have their own file type and extension. They have to be explicitly added to projects with the add framework command. In this case, the JSON "framework" wasn't a real framework but just a standard source file.
TechZen
A: 

I've managed to solve this issue by removing the references and reference my project again by following the guide on the how to add the Three20 library to an existing project but adding my own utility project. The guide is located in http://three20.info/setup/existing

lnetanel