Thursday, September 7, 2017

Can you use Deprecated Functions?

Hey guys, I am making a few tutorials but all are in progress right now. Hope to publish them this weekend. Anyways, as a frequent StackOverflow visitor, I often read programmers wanting to change the functions they used that are deprecated. From their postings, I get that many programmers think that deprecated means "cut off" and therefore cannot be used indefinitely. This is, false.

Let us take a look at the meaning of the word first.


Basically, it means disapproved (or in layman terms, not advised to be used). It is not the same as totally cannot be used in which case the word is BANNED. Deprecated is not banned. It is only advisable not to use the function. BUT YOU CAN STILL USE IT.

In iOS developer terms, you can surely use a deprecated function, but you must start thinking/planning/coding of the new function to replace it in 4-5 years time. Deprecated functions normally are supported for a long time before they are removed. This is because often, Apple creates new and better frameworks for a thing. But there will be many apps that rely on that framework that are already in the App Store. So to immediately ban a function, is an act of oppression.

For example, NSURLConnection. It was introduced in iOS2.0. It's successor, the NSURLSession was introduced in iOS7.0. So since iOS7.0, NSURLConnection is therefore flagged as deprecated. But can you still use it in iOS10? YES IT STILL WORKS. In iOS11? Nobody knows (except the beta users right now). Given 3 versions of iOS has passed, you oughta change it by now.

But if it was *just* deprecated in iOS9 for example, no sweat because that function will definitely be available even in iOS11. So if you're doing a quick update of your apps, very old functions that are deprecated (like the ones intro'd in iOS2.0), should be replaced. But if the deprecation appear in iOS8 or 9, you're likely safe to leave it as it is for now.

Hope this post has been beneficial. Happy coding!


Saturday, July 8, 2017

How to: Basic of XCode Methods & Functions in Objective-C

Why ObjC?

Cause we're oldskool! :D


INTRODUCTION

When we start to code, what we need to do is write methods on top of the already available delegates (namely the View Lifecycles delegates like viewDidLoad or viewDidLayoutSubviews). A typical method that we quickly create is IBActions. These are automatically created when you drag an outlet in Storyboard to your header file.


-(IBAction)aButtonWasClicked:(id)sender {
  // your button was clicked by user
}

The aButtonWasClicked: is the name of the method. Note that I include the semicolon at the end. This indicates there is a parameter to be supplied to the method. So if you want to call this method elsewhere programatically, you need to write:

Friday, April 28, 2017

How To: Seriously Plan and Design an iOS Apps or Games

Hey whatsapp? (see what I did there? XD)

All these while we've been playing with XCode and making fun things without much care of how our app's structure looks like.



The thing about making an app/software, there are so many ways to do one thing. So many ways to code a feature. But if you are serious in making apps, you need to consider your app carefully and thoroughly, so that updating the app won't be a pain in the a$$ in the future. This is more so, when making your own app, or an app for a customer that may be requested to be updated in the future. The overall structure and back bone of the app needs to be as good and as organized as possible. Otherwise you'll end up crazy, trying to make sense of things in the app or when you want to add a new feature to the app.

So what you should do? I now will outline the necessary steps and points for you to consider when making an app.

Sunday, February 26, 2017

How To: Create Undo and Redo in a Drawing App

Hi guys.

I want to share how to create undo and redo in a drawing app. I tried using NSUndoManager for this, but it doesn't work. Why? I don't know. When something don't work, I tried for a bit, and if I have no more idea to try and work it out, I simply abandon the idea and try something else totally. There is no point lingering on something that you simply do not know.

The way to implement undo and redo is quite simple really. You just detect user's end stroke, and then save that drawn image into a MutableArray. This will eat memory a bit especially if you have a very big image. Alternatively you can simply store the drawn image in the TMP folder of your app sandbox use names like "undo0.png, undo1.png, undo2.png...". Have a global undo index variable to keep track of the undo/redo steps. When undoing, you -1 to the index, and load the image based on this index number. And when redoing, you +1 to the index, and load that image.

Something like this:


-(void)undo {
undoIndex -= 1;
NSString *imageName = [NSString stringWithFormat:@"%undold.png",undoIndex];
yourImage.image =  [self loadImageFromTMP:imageName];
}

-(void)redo {
undoIndex += 1;
NSString *imageName = [NSString stringWithFormat:@"%undold.png",undoIndex];
yourImage.image =  [self loadImageFromTMP:imageName];
}


Of course, you have to handle the undoIndex limits (>=0 and <maxUndolevel). Simple right? Kthxbai.

Sunday, December 4, 2016

How To: Create Custom Objects in iOS Apps

Hey guys. Another noobies tutorial!!!!! First, an intro. My latest app just been approved by Apple so I guess I will write about that (HA!! :P) The app is called QuikFlix. It is a movie database app. I made the app because I needed it. I was always trying to find old movies that I want to watch. For example, particularly, I wanted to find top/popular comedy movies in 2013. How do you go about finding that? Google works I guess. But navigating in browser really sucks. So I created QuikFlix with all the features that I WANT: Search movies by Genre, Year and Popularity. Plus, I added main casts list in there with movie synopsis. And you can easily see photo of the cast by tapping on their name. AND I also create a simple WishList so you can add movies you want to watch in this list. AND!!! I also added theme color. It is free app check it out here:

https://itunes.apple.com/by/app/quikflix/id1169970723?mt=8

I used TheMovieDB.com public API for this app. Their API is really good in my opinion. You can do a lot more actually (like have user accounts, rating ability).

Anyway intro finished, Lets begin tutorial. :D Here is what we're gonna make:



Cool huh? Btw, the more accurate title for this tutorial is "How to Subclass / Inherit an Object", but those words are intimidating aren't they? What does subclass means?

Sunday, November 27, 2016

How To: Embed SpriteKit In UIViewController

Time for another simple iOS Tutorial!

First, a witty intro. It is not always best to be the first. Sometimes, being last is best.


Saturday, November 19, 2016

Tuesday, May 17, 2016

How To: Fix XCode 7 Lag

Hello darlings. This is not a coding tutorial but related to XCode so I post here.

XCode lag when switching between files?

I am using XCode 7.2.1 and Yosemite, and suddenly XCode lags when trying to switch between ViewControllers. I have tried many solutions suggested in internet:

Tuesday, January 12, 2016

How To: Using SLRequest to Upload Image or Video To Twitter

Hi guys what's up. This is a simple tutorial so it doesn't have any downloadable project.

Today I'd like to share with you how to upload an image (like JPEG or GIF animation) to Twitter from the iOS app.

For a normal JPEG and status upload, you can use SLComposeViewController but you will face problem if you want to upload GIF animation or video file. That is because SLComposeViewController only has "addImage" method that takes up a UIImage object.

Wednesday, November 18, 2015

How To: Pre-Process Tilemap Overlays in MKMapView

Hi all.

Time for another tutorial. Recently I was trying to modify a tilemap returned from a typical public map overlay server (such as openstreetmap.org) - basically I needed a way to change black areas of the tile into transparent so that I could nicely overlay it on top of MKMapView. I searched for this for a while, found some solutions but did not really work as I wanted. Some examples used MKTileOverlayRenderer. Somehow that gave me weird results that I do not understand.