Swift is Confusing: Classes, Structures, Designated Initializers, Instance Methods, Type Methods, Functions, Methods, Convenience Initializers & External Parameter Names

Class vs Structs Both: Store values, initialize, subscripts, extensible & protocol Class can inherit, de-initialize, reference counting & typecast Functions vs Methods Methods are FUNCTIONS INSIDE A CLASS Functions can be inside or OUTSIDE A CLASS! Cannot use functionName(param1,param2) to call a function declared inside a class {} Methods: It is implicitly passed the object for which it was called It is able to operate on data that is contained within the class Instance Methods vs Type Methods (Instance Method vs Class Methods I think) Methods are functions that are associated with a particular type. Classes, structures, and enumerations can all define instance methods, which encapsulate specific tasks and functionality for… Read More

Continue Reading
Swift Optionals Quick Reference for Newbies by Santiapps.com

Swift Optionals Quick Reference

Optionals confuse me so I wrote this post and hope it can be of some help. OPTIONALS Takeaway #1: Optionals are used to declare a variable but are not assigned a value at start Takeaway #2: Optionals contain a Some or None value, they DONT contain a String or Array or whatever else. Takeaway #3: Therefore we MUST unwrap the value of an Optional to see what the prize is 🙂 In other words, to access its value! Takeaway #4: DECLARATION OPTIONS A) Using the following syntax: var someVar? – You will mostly use this… B) Using “var someVar!” <Implicitly unwrapped> – Unfortunately UIKit & other Apple frameworks will use a lot of… Read More

Continue Reading

Why, oh Why, did Apple take away ARC just to give us Optionals!?

I’m having trouble understanding optionals so here is a shot at explaining them. 🙂 var thisIsAnInt: Int Simple, this is an Int variable declaration. var couldBeAnInt: Int? This on the other hand is an optional variable declaration. This optional declaration doesn’t mean: “this is an int, which is optional”. It reads more like: This is an OPTIONAL variable.  It’s a type of variable in and of itself.  Its NOT NECESSARILY an Int.  It just may or may NOT contain an Int”. Woah! Ok so what is it for and when do you use it.  Well that part seems simple enough: If that variable can or could or may be nil… Read More

Continue Reading

iOS7 – UIKit Dynamics

iOS7 Series – UIKit Dynamics   Incorporating UIKitDynamics into your app is pretty simple!  The great thing about it is that you really get the most bang for your buck because the end result has a really big WOW Factor which is certain to impress your users.  Let’s take a quick conceptual drive around UIKitDynamics. First we adopt the protocol into the ViewController which will implement UIKitDynamics, why?  Well because the objects which will be animated in the end will have to send back a lot of signals like “Hey, I collided with a boundary” or “hey I just hit somebody else and I was going this fast, in this… Read More

Continue Reading

iOS7 Sprite Kit for Game Design for iPhone & iPad

iOS 7 Series – Sprite Kit Welcome to iOS7 and to start off, I want to kick things off with SpriteKit.  Although it deals with video games, many companies are using iOS apps as a marketing tactic to engage their users in an effort to promote their products. SpriteKit is the most prominent feature in iOS7 so we’re going to take a quick tour.  Go ahead and create a New Project in XCode5 and select the SpriteKit template (the bottom right icon): Click next and fill in your project data.  Once you are in the main XCode window notice we have the following files in the Project Navigator: 1)   AppDelegate… Read More

Continue Reading

How to create an app – Not programmatically

A fellow coder asked: “How does one go about developing an app from scratch?  Where does one start?” My response follows: Some will say its a matter of style and you have to find your own. And eventually you will, after a lot of copy-paste programming. I started in 2009 and my first app was a copy-paste of a few different projects. All the app did was connect to the Internet, download XML and parse it into a uilabel. Then I decided to look into more complex app samples. So I downloaded a few from Apple. In particular I remember iPhoneCoreDataRecipes. In hindsight, it was too complex for a beginner… Read More

Continue Reading

iPhone needs a Siri button

Apple’s iPhone desperately needs a Siri button! From the beginning of time (in other words, 2007), the iPhone has only had the Home button. Well, and yes, the Power button. Ok, ok, and the volume buttons! Throughout every iteration these buttons have remained constant. From time to time, the OS added varying functionality to these buttons such as Assistive Touch or Mute/Rotation Lock. But overall their main functionality remained the same. The bottom line is, there is a reason why mechanical buttons are limited in today’s touch era. Mechanical objects offer greater probability of malfunctions than do their digital counterparts. Case in point, the now ubiquitous and quite profitable iPhone… Read More

Continue Reading

GrandCentralDispatch & Blocks

GCD helps improve your apps performance and responsiveness by outsourcing processes that require a lot or computing power to the background while keeping your UI responsive.  Normally you might want to do some heavy lifting. Let’s create an Empty Application.  You need to declare a IBOutlet UIImageView *imageView ivar in your appDelegate, make it a property and synthesize it in .m and make the connection in Interface Builder, IB.  In it’s viewDidLoad method put the following code: // Download the image NSURL *url = [NSURL URLWithString:@”http://www.santiapps.com/assets/bbkoko.jpg”]; NSURLRequest *req = [NSURLRequest requestWithURL:url]; NSURLResponse *res = [[NSURLResponse alloc] init]; NSError *err = nil; NSData *data = nil; data = [NSURLConnection sendSynchronousRequest:req returningResponse:&res… Read More

Continue Reading

iOS UI Refresh

iOS is undoubtedly a great touch UI. However, it needs a refresh, it’s long overdue for an overhaul.  Not just a “new widget” type refresh but a real overhaul.  If we can make a robot that flies millions of miles to explore a hostile planet… SEARCHING FOR APPS The whole repetitive process of searching for apps in the AppStore, installing them, updating them everyday and switching between them is getting so old, so 2012! We’re are in the era of Robots that travel millions of space miles to do their thing. Robots that park cars, help the elderly etc. Our robots are getting smarter by the day. We need our… Read More

Continue Reading

Faulty Damaged iPhone Home Button Not Working

I’ve read many a posts… on many a forums… suggesting many a solutions… none have worked for me: press, hold and circle your finger around it a few times blow compressed air on the button and the pin connector shutdown this or that other applications…or all of them press power button til slide to shutdown, then press and hold the home button to reset it connect the cable and gently press the cable connector upwards…and downwards… all to no avail. and i dont have the option to return it cause its australian so a US store wont take it. I have recently noticed that when it is docked into my… Read More

Continue Reading

Power Hungry Devices

Its funny how capitalism leads to consumerism and that it turn, in a free democratic society, is fueled by our “NEED” for more and more services.  What this translates to is the fact that we want more and more “things” which we request from our technology.  So everyday we come up with things we want our phone to do for us.  First, the beeper simply sent us text messages for us to get to a landline and call.  Then it allowed us to answer text messages.  Soon after came the cellular phone and we didn’t have to go to a landline, we could simply call on the mobile phone.  But… Read More

Continue Reading

iOS5 Important Features from 200+ available

I’ve reviewed the latest features on the latest iOS5 on many sites and found over 200 out of which only some are really useful to me.  Id like to share the ones I found most important: 1) Swiping a notification will open the relevant app 2) The fact that those notifications are non-obtrusive to YouTube videos 3) Reminder, Calendar, Contacts, Mail, Photo and Doc Integration to iCould because Gmail makes a mess 4) Twitter Integration 5) Open Camera from lock screen although picture taking with the Vol+ button is only for the 4S I think 6) Cropping, Rotating, Organizing and Red-eye removal on pics directly 7) OTA syncing & Delta… Read More

Continue Reading

Pointers, Leaks, Memory Management…objC

Ive been coding for about 2 years now and i recently understood something which has helped me a great deal so i wanted to share it with you.  First let me just expose my learning path so you can determine if its comparable to yours and decide if this article may be of help or just good for a few laughs 🙂   Little HS and College programming background.  Biochem (heavy math and science background).  Picked up HTML and ASP on my own with books and online sites.  Did that for about 4 years.  Picked up iOS at 3.0 and started out using stanfords free online course and made a… Read More

Continue Reading

Oreilly Learning iPhone Programming

Currently on Ch5 but have a few questions looming in the back of my mind: 1) Why use a tableviewcell to enter data for AddNewCity instead of a UIView with label and description? 2) Just as i thought, tag 777 got me in trouble.  My bad because i added the tag to both the inner component uitextField and the outer component tableViewCell by mistake.  But im wondering  a couple of things: (a) can i tag the entire structure uitableViewCell as i did (without tagging the inner components) and get any component inside it with that tag refrence? (b) why exactly was it not passing the data correctly; because the outer… Read More

Continue Reading

Delegates & Protocols iOS

A complex subject to wrap your head around, i agree!  But its pretty cool once you get a working example going. Let’s think of a game where a lander comes down from the sky (presumably on Mars – since Mars is a hot topic lately) and deploys a  rover.  In Cocos2d, you put all your objects on a Layer object.  This means the layer class is the main class (analogous to a viewcontroller class contains buttons, views, labels, cells etc). You create a Lander object class because you want to re-use it everywhere in the game.  With every new level, you must create a new layer class but you can… Read More

Continue Reading

iPhoneCoreDataRecipes Explained…

Im going thru this Apple app and im noting my progress in understanding it.  Any comments are appreciated. black = unanswered questions red = my answers so far blue = partially answered on the blog itself green = less important, design questions maybe… RecipeListTableViewController.m 1) Why @class Recipe and @class RecipeTableViewCell 2)  They adopt a RecipeAddDelegate & NSFetchedResultsControllerDelegate protocols? YES…Ive never seen a protocol before.  I guess the NSFRC protocol class is a UIKit class but i had never seen a customcreated class be used as a protocol…COOL! 3)  Why do we declare showRecipe & configureCell methods but not the add:method or the whole bunch of others…. 4)  When creating… Read More

Continue Reading

iLuvMe took OFF in Feb!!!

The iLuvMe App was a hit in Feb! We are pleased so many of you out there downloaded our app and even happier that you liked it so much to write us with thank-you comments from your valentines who so enjoyed it. Just wanted to drop a note to say you’re welcome and were hard at work on version 2.0 with more features as well as on other apps for other end users such as business, entertainment and more! Santiapps.com will keep you posted when new apps become available. Thank you for your support.

Continue Reading

Presence3:NSThread & NSOperation

Im looking through Presence3, understand the LetsMakeAThread project, its pretty straight forward, detachNewThread creates a separate thread and performSelectorOnMainThread returns you to the MT, but in ThreadedFlickrTableView, whats the deal? beginLoadingFlickrData calls a new invocation operation, which loads synchronousLoadFlickrData: which gets the data from Flickr and returns to MT via didFinishLoadingFlickrDataWithResults: which in turn creates the arrays from the FlickrData. Then cachedImageForURL gets called from the cellForRowAtIndexPath?  And so that same method calls the ImageLoadingOperation which then returns to the main thread via didFinishLoadingImageWithResult:? Is this chronology correct?  The MT gets separated or stopped 2x in this app? Once in beginLoadingFlickrData and then in cachedImageForURL?  The difference being that in… Read More

Continue Reading

Plists, SQLite, Write2Disk, PassingData VC

Im working my way thru Lecture 9. Recapping what ive done, i created 2 Preence2 projects; first i pass data using the custom initWithpassedData: method which didnt let me use the initWithStyle for the tweets table view, and second I used the appDelegate pattern which i dont like cause its really a global variable. So Im looking into KVOs and NSNotifications but they look kinda scary! I started using plists for a couple of projects, found out they can be further structured to no just a simple array or a dictionary with keys and objects, but also kind of a flat db with parents and childs. Ill try using plists… Read More

Continue Reading

Stanford Assignment 3 HelloPoly: 1 Control/Multiple Actions

I should have known this from my experience in Flash!  The solution to why it only draws the first polygon is that the same buttons, Increase and Decrease, required multiple, in this case 2, actions, not just one.  Basically you need to define another method, inside the polygonview, which calls setNeedsDispaly.  And hook up the same buttons in the nib file to that method.

Continue Reading