iphoneobjective-ciphone-sdk-3.0

Is it possible to create a CLHeading object in Objective C?


I'm trying to implement a drop-in location manager subclass to allow me to pass heading data to the iphone simulator, similar to the unimotion/accelerometer hack. Unfortunately, according to the CLHeading docs, everything is read only and there's no initialiser which allows the heading to be set. Is there a way to force the creation of a populated instance of CLHeading?


Solution

  • Since Objective-C is a dynamically typed language, you can create your own class (for example,MyFakeHeading) and as long as it responds to all of the same selectors that CLHeading does, you can simply cast it as a CLHeading and pass it as a parameter instead. And, since you only need to fake out your own code, you don't even need to implement all the functionality of CLHeading, just the parts your are using.