Saturday, November 18, 2017

How To: Make an App That Uses Public API (Openweathermap.org) Using NSURLSession

I think I mentioned somewhere (and maybe everywhere) that I love JSON. I LOVE IT! JSON is basically like NSDictionary. Every entry has a key and a value. And you can go nesting too - like a dictionary of dictionary of dictionary. O_o

// this is a bird's nest

What we're going to make:
2.5MB GIF

JSON is structured and that is why many web service opts to this format for communication between a client and server. In the old days, or even now, some web service still use obscure format like user-defined text strings separated by pipes or commas (CSV). Something like:

Tuesday, November 7, 2017

More Contribution to XCode Community!

One of my friends asked me, you get a lot of revenue from writing tutorial blog? My answer is - NO. I get like 0.001 cents per day from my blog currently lol. My blog isn't famous like appcoda or raywenderlich. So why do I keep on doing it? Simple - I always view that anything I learn, is an inspiration that is meant to be shared to everyone. I do it because I love to share what I know. Often, I faced with a problem to do something in my own apps, and upon finding a solution I like to document it, because I am sure others might have the same problem or obstacle. By sharing what I found or created, we advance together.

Enough intro. Anyway this post is a short one. I just want to announce yet another contribution that I am making towards the XCode Community - MY FIRST EVER GITHUB REPO!!!! OMG! Sorry I am too excited for this.


First repo is a flexible Toolbar/Tabbar. I have added a list of my Github repo in the left bar for future reference. Well, that's about it for this blogpost. I am thinking to redo the Switchy object as a proper repo next. Stay tune. Or not. Whatever dude and dudette.

Ps. I forgot to put the link to my main GITHUB REPO: GENECODE GITHUB

Saturday, November 4, 2017

How To: Use Reusable Views Correctly (TableView, CollectionView, etc)

First, some short intro! :D My blog views has finally reached ONE MILLION!!!

Now if I get a dollar for a view. Phew! None the less, I am so happy with this view count- why? Because it means I helped quite many developers to create their apps (hopefully). And those apps will benefit mankind. Even if it's a fart app, hey, it cheers up people and that is good.

As noobs we tend to not getting the whole picture of a particular UI object. A label is simple, there is text property, you set it directly in Storyboard or programatically (label.text = @"hello";) and it shows immediately. Pretty straight forward. But for objects that uses Reusable Cells like TableView, there are multiple set ups that we need to do to use it properly and therefore prevent any weird and unwanted bugs and crashes. Anyway here's what we're gonna end up with at the end of the tutorial:


It's a 2.4MB GIF.


What does Reusable Views mean? 

It is basically a concept/method to display big amount of data in a scrollable area. In case of TableView,  the amount of cells being created by TableView is only a small quantity that is enough to fit the visible area of TableView.

For example, if you have TableView of height 300, and each cells height is 10, then at least 31 cells are created at runtime. And when you scroll down the table, the cell that is being pushed out of view