Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 703
Shabbyrobe Avatar asked Feb 10 '10 05:02

Shabbyrobe


1 Answers

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.

like image 91
benzado Avatar answered Nov 03 '22 23:11

benzado