Are all iOS APIs in swift... also available in obj c

I am returning to app development after 4 years and I want to know if all iOS apis that are in swift also available in obj c or has apple gone swift specific now? I came across an Api that doesn’t load the obj c version of the api. I want to know before getting in again if it could be a bug or one should expect only swift apis and learn swift inadvertently.


Neerav

Accepted Reply

I asked:

"More to the point, what is your question?"

You answered:

"So objective c is still default supported except for APIs that concern only swift language & language Features."


I'm not sure there is a question there. Objective C is still supported and will most likely be supported for many years to come. Many new 'how to do that' code descriptions are written only in Swift as you have just discovered.

Replies

Which API couldn't you use in Objective-C? Most APIs are available in Objective-C and Swift, but some of the frameworks introduced in iOS 13 are Swift only, such as SwiftUI and Combine.

This is available in Objective C as is everything. Swift is a superfluous attempt to obfuscate, IMHO.



IAP programming is difficult. Don't try it unless you understand Objective C; at the very least how you create a new class. Here the new class would be called iapObserver.


The equivalent Objectove C commands are


            [[SKPaymentQueue defaultQueue] addTransactionObserver:iapObserver];

// and

           [[SKPaymentQueue defaultQueue] removeTransactionObserver:iapObserver];

// and the method that is called in iapObserver is


-(void) paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
Post not yet marked as solved Up vote reply of PBK Down vote reply of PBK

Did you write this code or did you copy paste. I don't see the objective c code at all. I only see swift code. I understand objective c.

Your last post is in reply to "edford". Assumming you meant to reply to my post, the lines I posted are Objective C. Specifically, these are written in Objective C:


     [[SKPaymentQueue defaultQueue] addTransactionObserver:iapObserver];  
     [[SKPaymentQueue defaultQueue] removeTransactionObserver:iapObserver]; 
-(void) paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{

Sorry. That was in reply to you. So these lines are from the Documentation? Or did you write it?

I wrote them. The documentation you reference is clearly wrong. Please file a bug report.


More to the point, what is your question?

So objective c is still default supported except for APIs that concern only swift language & language Features.

I asked:

"More to the point, what is your question?"

You answered:

"So objective c is still default supported except for APIs that concern only swift language & language Features."


I'm not sure there is a question there. Objective C is still supported and will most likely be supported for many years to come. Many new 'how to do that' code descriptions are written only in Swift as you have just discovered.

"So objective c is still default supported except for APIs that concern only swift language & language Features." Sorry but yes that was the question. So the article on 'Setting Up the Transaction Observer and Payment Queue' has code in swift and is entry point to setting up in-app purchase. Since i am coding an app that will be free with in-app purchase, my entry point is setting up necessary capabilities in xcode for the same, setting up the portal with necessary in-app purchase info and then writing code for it. I got stuck at the very entry point. As much as swift is marketed to be simple, i find its syntax confusing. In any case, thanks for your answer. Your answer means objective c is supported and one 'can' expect that all APIs and documentation (guides, articles, etc..) will have objc version of any code they consist (sans swift only APIs). I'll file a bug report. Thanks.

>one 'can' expect that all APIs and documentation


Unfortunately, not documentation. But older api's, like IAP, will have archived code and documentation in Objective C. Search for it.

I understand. There are c APIs and swift language specific APIs etc. But most APIs in most framework works are in obj c. So unless where obj c is not applicable, the api is in obj c. As u said, in case of the one i linked, 'clearly wrong'. I'll file a bug report. Do u know of some app or online tool that would convert swift code into obj c code?

>Do u know of some app or online tool that would convert swift code into obj c code?


No I do not.

i came across another documentation i need with the same problem...


https://developer.apple.com/documentation/healthkit/setting_up_healthkit?language=objc


this problem persists across safari and chrome and even in the bundled xcode documentation.

Just to clarify, is the issue you’re reporting here that the code snippets within that page are in Swift? For example, in the Ensure HealthKit’s Availability section there’s this code snippet:

if HKHealthStore.isHealthDataAvailable() {
    // Add code to use HealthKit here.
}

and it displays as Swift even if you have the Language popup at the top of the page set to Objective-C.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"