0

I have a static library project and an iOS project in one workspace. There is a class FCPlayerData in the static library. I subclass FCPlayerData as PlayerData in the iOS project.

The problem:

I need the static library to reference PlayerData (the subclass) that is in the iOS project but it doesn't recognise any of the properties of PlayerData and when CMD clicked, says "Symbol not found". How can I import the subclass from the iOS project into the static library?

Thanks in advance.

4

3 回答 3

0

If you only need to add few methods to the FCPlayerData you can use Categories to add those methods directly to the FCPlayerData. Look here for more on categories: http://krodev.wordpress.com/2012/09/29/objective-c-categories/ or here http://cupsofcocoa.com/2011/03/27/objective-c-lesson-8-categories/

于 2013-08-13T11:21:05.757 回答
0

If FCPlayerData is a subclass of PlayerData it would be safe to pass an instance of type FCPlayerData.

Or you could add the header and implementation files for the subclass to the project but that would cause a cross dependency between your project and the static library.

于 2013-08-13T11:28:39.667 回答
0

I've looked into the answers, however, in my situation a category is not suitable.

I found a solution:

In the static library, I created a property in my FCReferences class as such: @property(strong, nonatomic) id playerData;. Now, in the static library, I only need to access the core properties of FCPlayerData so to access them, I cast it using ((FCPlayerData*)playerData).myProperty. In the iOS project, I need to access the additional properties of the subclass, so I cast it as ((PlayerData *)playerData).additionalProperty.

Note: PlayerData is a subclass of FCPlayerData.

于 2013-08-13T11:40:45.433 回答