I am playing around with a mapping iOS app, using MapKit.
I would like to use Kingpin as a clustering library but I am using swift and the guide is objective-c only.
I create the cluster controller
var clusterController = KPClusteringController()
and add the delegate to the View Controller
class ViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate, KPClusteringControllerDelegate {
However I can't seem to be able to call the initWithMapView method, what am I doing wrong?
PS: the library should be imported correctly as both KPClusteringController and KPClusteringControllerDelegate are suggested by Xcode.
EDIT
I should be able to initialise the clustering manager like this
self.clusteringController = [[KPClusteringController alloc] initWithMapView:self.mapView]
However I have no idea how to do it in Swift :/ I would expect Xcode to give me a suggestion, but something might be loading properly.
Full kingpin doc here https://github.com/itsbonczek/kingpin
However I have no idea how to do it in Swift :/
As described in the Initialization section of Using Swift with Cocoa and Objective-C, in Swift you do this:
clusteringController = KPClusteringController(mapView:mapView)
The fact that you're using CocoaPods to manage this framework doesn't have any bearing on the situation. You just need to learn enough about Swift to translate from Objective-C.
Related
I have a project for tvOS written in Swift. Now I received a TVML document that I need to use in my project. What should I do? Can I initialise a UIViewController instance with a TVML document?
TVMLKitchen helps to embed TVML documents in tvOS apps written in Swift. It has everything that I need to solve my problem and it is easy to use. I hope that it will be useful for all tvOS developers.
I just learned about UICollectionView after creating the same functionality in a custom class. So I am thinking about using deleting all that code I wrote and just using UICollectionView.
I know my app gets a lot of installs on iOS 5. And I know a lot non tech savvy friends and family still have it installed.
I googled this and it says I can use some other's guys library(another thing I should have known before writing my custom class). But the answer was not definitive.
So my question is, does Apple include a bridge for iOS 5 or will my app just fail if I use UICollectionView?
I have my target deployment set to 5.0 and it is not giving me any warnings.
Venkat
UICollectionView is iOS6 only. You can include extra code to check for iOS6 and use your custom class on iOS5. But there is no way to use an actual UICollectionView in iOS5.'
Thats what that "other guy's library" does. It has an iOS5 compliant clone of UICollectionView and checks based on the OS which to use.
Maybe you want to try this as an alternative:
https://github.com/steipete/PSTCollectionView
It seems that a lot of customization in iOS requires that one override the default behavior of elements in UIKit by either using categories or subclassing.
How does one view the inner workings of classes such as UIButton and UIWebView without documentation? For .NET, there's Reflector. Does anything like that exist for Cocoa?
There is pretty good documentation. For example, UIView programming guide, UIButton and UIWebKit. Search for the apple programming guides and * class reference. I would recommend reading all the programming guides, using the class reference docs and above all, write sample code using the controls to understand exactly how they behave.
.net, is compiled to IL and JITted to native at runtime. So, it's fairly easy for something like reflector or ILSpy to not only be able to reflect over the metadata at runtime but also reverse engineer the code.
Objective-c and C code is compiled into native code so you won't get it reverse engineered into readable code like those. The only thing I've seen is otx: http://davegoodell.blogspot.com/2009/05/otx-objective-c-disassembly.html
In addition to what bryanmac said, you can also dump the view hierarchy recursively by sending any UIView instance a recursiveDescription message. For more details, see Technical Note TN2239: iOS Debugging Magic.
Edit: But please be aware that modifying the view hierarchy of most Apple-supplied UIView subclasses is forbidden, and iOS 5 has introduced other ways of customising the look and behaviour of them.
I tried archiving an NSAttributedString in Mac OSX 10.7 and then tried to unarchive it in iOS 4.. I get an error:
cannot decode object of class (NSParagraphStyle)
I see that there's no NSParagraphStyle in iOS. So my question is, is there a workaround or is it not possible to this?
Perhaps you could use the NSKeyedUnarchiver method setClass:forClassName and provide a class of your own to use for NSParagraphStyle. That class would have to implement initWithCoder: and you could either ignore it or try to replicate NSParagraphStyle with what's available on iOS (CTParagraphStyle which is quite difficult to work with).
I am developing an iOS app where I am recording sound from the devices mic, saving it to a wav, then it needs to be accessed and played from a different view controller. As I understand, a FMOD::System object can only be defined in one view controller.
What would be the best way to access FMOD in more than one view controller?
I have tried using a Singleton class, however with objective-c's lack of class (non-instance) variables, I am not sure how declare the FMOD::System variable.
Has anyone successfully implemented what I am trying to do? Any help appreciated!
Thanks
I ended up making a singleton class and got it working.
If anyone would like help doing the same just ask.