Group Group Group Group Group Group Group Group Group

Swift abilities

I must say that the language is most amazing after programing in the stone ages…the ability to go beyond object oriented concepts is amazing with concepts of late binding…! Yes you all already know this…but consider someone that knows C and C++ 30 years earlier? Something to share here as I know how Swift was created but am learning how to use it like I did with C++…

Somehow you overlooked late binding in C++?

I too was once a stone age C++ programmer, which was an interesting and challenging intellectual exercise, but then I realized that I couldn’t program anything of consequence with C++ . Then I switched to a language that I had heard about a couple of times, but which I knew nothing about, Python, and suddenly I could scrape web pages, program with sockets in less than 250 lines of code, etc., etc.

Because of Optionals, I find Swift to be an extremely distasteful language when used in iOS programming.

Not exactly, what I meant was related to Swift/Obj-C is the optionals and lazy creation of objects. Type casting even in C++ is much more strict than Swift. I am still learning the language. Even type casting items for JSON serialiation like an array of dictionaries, like [String:Any] with some of the ANY’s being NSArray or NSDictionary being set…somewhat complicated to access the data and deal with the type casting and optionals…It could not even be done like this in C++.

Anyway, enjoying the Swift learning…

Swift’s JSON handling is terrible. If you are interested, see SwiftyJSON for an alternative.

Anyway, enjoying the Swift learning…

You, too. :slight_smile:

I must definitely agree, Swift JSON is the worsted! Any other language PHP Python JavaScript etc are much better. That is just Apple… unfortunately.

Hi @kary993, thank you for sharing your thoughts on Swift. I love what Swift has to offer and really enjoy the iOS development side too. I’m learning something new everyday using Swift. I’m looking forward to it’s future. Happy coding!

Best,
Gina

@kary993 I highly recommend you use Swift 4’s features in JSON parsing without using Serialization. By simply implementing the Codable protocol, you’re now about to conveniently map your JSON data to model objects quite easily!

I would certainly agree using the Swift 4 JSON capabilities if they worked in my situation. Since the JSON return stream did my have an identifier for the array of dictionaries, I was forced to use serialization since JSON could not interpret the sequence correctly. Further, there were “null” values in there that I am still having an issue with even with serialization. So perhaps I am not understanding something, but there are some situations where the new JSON features simply do not work. I can post the example if there is interest but thought this topic might be a bit off topic for this forum?

I have been working hard on learning what I stated before as not working. I have found I can do what I need to do without serialization. A combination of the iOS 11 book by you all and some other websites helped me to understand what I was missing.

So now I see how this works. I find much of the advice for latest Swift and Xcode to be highly inaccurate on the internet. So thank you for your accurate portrayal of how it works. There are a few things that would have helped me understand had they been there but then nothing can be explained perfectly for everyone.

Thanks again!

Hi @kary993,
Glad to hear that finally you are closer to your goal and have a better understanding.

One thing that I can tell you from my experience is that not all JSON fragments that are generated can be parsed because not all JSON is structured in a good manner. Secondly, if you are using Swift4’s JSON methods, you will require to mark quite a few fields as optional if the return JSON would not always have that/those fields.

If you look at JSONModel (for Obj-C) it works in a similar fashion. As regards to the information on the web being innacurate, well one swift is changing quite rapidly and secondly, the internet is the internet where everyone can post an opinion - you have to sieve through the noise to get the correct result.

cheers,

Jayant

This topic was automatically closed after 166 days. New replies are no longer allowed.