Call ios-charts fromObj-c - ios

I try to use ios-chart (Swift framework) from my objective-c project.
And I don't use storyboard or UI-designer. I program. :-)
Is there anyone who can hint me how to open a LineChart or other chart from my UIViewController?
My best guess so far is to create a subclass from UIViewController and programatically add a BarChartView provided with my data that should be plotted.
I thought I would find a UIViewController in interface folder but havn't done that.
Any example or hint is appreciated!
Kind regards.
Jan Gifvars

https://github.com/danielgindi/ios-charts
Repository contains ChartsDemo folder with real examples written in objective-c. You can use it as an example.
If you want to install this library as pod using cocoapods, then you to include use_frameworks in your pod file.

swift is callable from Obj-c and vice versa, guarenteed by apple:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
btw, if you need to support iOS 7, use ios-charts source code directly.

Related

How could I use SnapKit in Objc project?

I create new project with CocoaPods (Xcode 9.3.1 and Swift 4.1)and of course use SnapKit in it.
and I want use third party class TreeView ,this class wrote by Objc.
How cloud I use SnapKit in class TreeView ???
I try to use the following steps but not working:
create new file named SnapKit-Bridging-Header.h
go to TreeView.m , import the header file (notice:It ends with '-Swift'):
#import "SnapKit-Swift.h"
compiling now is OK! and I can see LayoutConstraint (defined in SnapKit)and some other class in TreeView.m file
but when I use view.snp.xxx ,it complain "Property 'snp' not found ..."
So my Q is How could I use view.snp.xxx in ObjC file??? Thanks :)
Swift code is not fully interoperable with Objective-C.
You can only use such Swift elements in your bridging header that are supported by Objective-C. This library requires Swift, it doesn't say that it supports Objective-C, so it's likely you need to do extra adaptation efforts to support it.
In iOS 9+ you have NSLayoutAnchor API that is almost as easy to use as SnapKit
(see https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/ProgrammaticallyCreatingConstraints.html ;
https://cocoacasts.com/working-with-auto-layout-and-layout-anchors/ ; https://theswiftlibrary.com/the-simple-way-of-creating-constraints-in-code)
This API is easy to use and compatible with Objective-C.
If you want to support iOS 8, you can use a backporting library like this one.

iOS panoramic app: PanoramaView porting on swift

I need to show some 360 degree spherical photos and was trying to use the RobbyCraft's Panorama repository on Github. I'm able to get the Obj-C project running well, but I don't understand on how use the swift example described by Fabien here.
(By the way I know that I can also use the Google Maps API to render panoramic photos, but I'm afraid that it's a more complicated approach for my needs...)
I made a swift app with a GLKitViewController. Obviously I get "Use of unresolved identifier 'panoramaView'...
Must I use the "Bridging-Header.h" declaration ? (I mean #import "PanoramaView.h")?
I tried to do so, but then I'll get many errors on PanoramaView.h itself.
(PS. I added the needed frameworks to my project, too)
In the Bridging-Header.h file add the following line on top
#import "PanoramaView.m"
In PanoramaView.h, at the top add
#import <GLKit/GLKit.h>
I had same problem and this solved it

Issues while using swift code in objective-c

I am very new to iOS who is trying to use swift in objective-c. I created a swift class in the objective-c project and i am able to call that class from an objective-c view controller.
The problem is if i make any changes in the swift code, it doesn't seem to be available immediately for objective-c class to access. Each time i change something in the swift class, i will have to build the project and only then it seems to be available in objective-c.
Is there a configuration that i am missing or it is expected to work this way by design?
Please read this explanation from apple. Read the sub-heading "Importing Swift into Objective-C". The generation of header files might be the explanation for your issue.
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html#//apple_ref/doc/uid/TP40014216-CH10-ID122.

Objective-C to Swift bridge

I have to make use of an API which is written in Objective-C but my application uses Swift. I have heard of bridging concept, but I'm not very sure of how to implement it and make use of it in Swift. Is there any other way to make use of Objective-C in Swift?
Unfortunately, No.
You have to make use of bridge for it. Check this link (Apple)
Using bridging header is recommended way and pretty simple. xCode can even auto generate it for you. Follow the instructions here to see how you can implement it and make use of it - http://www.learnswiftonline.com/getting-started/adding-swift-bridging-header/

how to use SPGooglePlacesAutocomplete in ios

i am using this objective-c wrapper to get the Google Places Autocomplete API result in search bar. i am able to use this sample .but when i copied all file in my project and want to use it i am getting lots of error. how to use it in iOS 8.to make to get Google Places Autocomplete . i am missing something here or what is this error .how to solve this.
import uikit.h into your header file.
#import <UIKit/UIKit.h>
and remove all autorelease statement. they are not allowed in to arc.
that will rectify your general issues.
I'm the one who created that CocoaPods repo you mentioned. It's out of maintenance, as you can find a better solution in Google Places SDK for iOS

Resources