Business of iOS Apps

I keep reading articles or watching videos of iOS businesses who made it and they share their wisdom of the Common 10 Mistakes iOS developers make. Guess what? Most of those mistakes, although they are worded as developer concepts, they are really business concepts. Common Mistakes: Don’t need a marketing guy. Don’t need a business guy. Don’t need a business perspective. Usually worded as, I thought I would get rich quick, or Im looking for a one hit wonder, or Im a great programmer and I thought that was enough. Well guess what, if you are going to sell something and make more than 99c for it, its gonna need… Read More

Continue Reading
NSURLSession vs NSURLConnection by Santiapps.com Marcio Valenzuela

Fetching data from an iOS app – The new NSURLSession API

Ok, this is gonna be short, I promise! ūüôā Do you remember those apps you’ve got stored away or the ones you are working on that fetch data from the web with a NSURLConnection? Time to update them, here’s how. Basically you have a method that calls a web fetch and is somehow signaled to use that received data to refresh a UI. If you used NSURLConnection sendAsynchronousRequest:, you have the issue that it blocks the main thread. It does carry out requests asynchronously from each other, but each request does indeed block the main thread since it is carried out in the main queue. Alternatively, you can use a… Read More

Continue Reading

Creating a Menu in SpriteKit

Cocos2d has a easy to use CCMenu object to which you add CCMenuItems. ¬†In SpriteKit however, you are back to UIKit objects. ¬†This doesn’t not mean its more complicated, its just different :-). ¬†You will need to create a UIControl such as a button or you can use SpriteKit’s SKNode to create the visual object onscreen: SKLabelNode*¬† someNode = [SKLabelNode labelNodeWithFontNamed:@”Chalkduster”]; [someNode setText:@”Play Game”]; [someNode setPosition:CGPointMake(CGRectGetMidX(self.frame)+5,CGRectGetMidY(self.frame)-40)]; [self addChild: someNode]; Now you simply connect the object action to some event like so: for (UITouch *touch in touches) { CGPoint location = [touch locationInNode:self]; if ([someNode containsPoint:location]) { SKTransition* present = [SKTransition revealWithDirection:SKTransitionDirectionDown duration:1]; GameScene* gameScene = [[GameScene alloc] initWithSize:CGSizeMake(1024, 768)]; [self.scene.view… Read More

Continue Reading

Swift Tutorial II

Ok so in the first tutorial we covered let, which is the keyword for defining constants. let thisBeAConstant = 3.141 Now we are going to cover variables, which use the var keyword like so: var thisVariable = time Notice 2 things about Swift: 1) We don’t use ; at the end of a line. ¬†That’s just weird ūüôā 2) We don’t have to specify the type. ¬†The type is inferred by whatever value you pass in, so: var someString = “this is a string” var someInteger = 5 So Swift is kinda smart. ¬†Now let’s meet some old friends “Hao jiu bu juan” ARRAYS var¬†energies = [“solar”,¬†“wind”,¬†“fossil”, “this is a… Read More

Continue Reading

Creating a simple UICollectionView in iOS

Steps 1) Create Master-Detail Application & Replace the MasterViewController First we want to create a Master-Detail Application just because it sets up a Master-Detail relationship even though thats the first thing we are going to break :). ¬†So go ahead and create a new project in XCode4 based on a Master-Detail Application type. ¬†Use ARC, Storyboards and CoreData because we will use CoreData to store information. ¬†Your storyboard should look like this: Now select the Master scene until its highlighted in blue and delete it with the Delete key. ¬†We simply replace it by dragging in a UICollectionViewController onto the storyboard in its place. ¬†This places a UICollectionViewController scene with… Read More

Continue Reading

iOS Smarties :)

Everyone loves Smarties! ¬†And much the same way Smarties Candies make you smarter…¬†today we are talking about Code Snippets that make you….er Smarter! ¬†More than a source of cut/paste Objective C source code, this is meant to be a quick reference. ¬†As such, some of these will be incomplete and I will be filling them up as I go along.¬† 1)¬†¬† UIAlertView UIAlertView *internetAlert = [[UIAlertView alloc] initWithTitle:@”No hay farmacias” message:@”Favor cambie sus par√°metros” delegate:self cancelButtonTitle:@”Cancelar” otherButtonTitles:@”Ok”, nil]; [internetAlert show]; 2)¬†¬† NSNotification //1. Register as observer of notifications in viewDidLoad [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveTestNotification:) name:@”TestNotification” object:nil]; //2. NSNotifCtr CLEANUP in viewDidUnload [[NSNotificationCenter defaultCenter] removeObserver:self]; //4. Post notif to NSNotif in… 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

ObjC Programming

The Big Picture ObjC is OOP which means objects send messages to other objects. Before getting into messages, let’s define objects. Objects. This is very diverse. An object can be a string, a number, a Boolean, an integer, an array, a dictionary or even one you create yourself. There are any types of objects but let’s start at the root object. The root object is called NSObject. You’ll see references to it in code but you’ll hardly ever use it directly. This is called the root object because it’s the starting point of any object. It’s like Adam and Eve rolled into one and ANY other kind of object in… Read More

Continue Reading

Static Libraries in iOS – Video Tutorial

Libraries is another one of those rather obscure topics for newbie programmers, kinda like Blocks and Delegates/Protocols. ¬†Think of libraries as just that, a resource you can use which doesn’t belong to you. ¬†A loaner ūüôā NOTE: If you need a nice tutorial on Blocks or Delegates, check out: Video Tutorial: Objective-C Blocks Video Tutorial: Objective-C Protocols and Delegates Ok back to our tutorial! ¬†Well a library is a piece of code that you can use (by importing it into your projects) but its not yours, so you can’t really do what you want to that piece of code, except use its functionality. ¬†In this tutorial we will create our… Read More

Continue Reading

Blocks & Completion Handlers

Think of blocks as c functions: (return type)functionName(input1, input2) { input1 + input2 } and you call it like this: return type = functionName (1,2) Blocks are similar: NSInteger¬†(^mathOperation)(NSInteger x, NSInteger y)¬†=¬†^NSInteger(NSInteger x,NSInteger y){ return¬†x¬†+¬†y; }; You call it like this: NSInteger sum = mathOperation(1,2); Now imagine how cool it is to, instead of just passing a value to a method (like saying: here is a value, evaluate it), you can pass a whole method to it (like saying: here is something else to do!). Or better yet, here do this but only when you finish doing that! Like, load the users posts or tweets after you finish authenticating him!… Read More

Continue Reading

Creating Reactive Cocoa Xcode project

  Earlier I posted an article on using RAC. ¬†It was a plain vanilla example of using RAC. While I AM working on a second post with more useful examples, I wanted to go over how to ADD RAC to a project.   First, you must have ruby installed. ¬† This means, go to Terminal and type in: which ruby This is what I get: …../.rvm/rubies/ruby-2.1.0/bin/ruby Important to note here that if you don’t have that rvm bit, you might still have ruby. ¬†RVM stands for Ruby Version Manager and for what little I know about ruby, its one of the managers available for ruby but there are others. If… Read More

Continue Reading

Reactive Cocoa in 3 simple steps!

If you made it through installing ReactiveCocoa, via Cocoapods, which required you to have ruby, update it and install Cocoapods and CLT, then you’re already ahead! ¬†So here is RAC. ¬†RAC is used when you need to be notified of something important in your app; completed download, some long asynchronous task like data fetching, parsing or image processing is complete or to update UI such as a completed form produces an active Submit button or an incomplete field yields a red warning sign to the user. How does RAC work? You basically create signals for events you are interested in (like the ones mentioned above) and then you tie those… Read More

Continue Reading

Why Im not excited about multitasking!

  MULTITASKING ISNT FOR US   Why Im not excited about multitasking! ¬†On iOS, OS X, Windows or any other platform, multitasking simply is not a good fit for humans. The reason is that while these operating systems might multitask and quite efficiently at times, humans and human brains more specifically, cannot multitask. Let’s take the typical working day. Let’s say that you finish eating lunch at home and get back in the car to drive to your office. On the way to work you remember that you have to pick up some groceries on your way back home. [toDoArray addObject:@”groceries”]; A few minutes later a call comes in and… Read More

Continue Reading

WWDC 2013 Videos of Interest

WWDC 2013 Videos of Interest Introducing Text Kit Advanced Text Layouts & Effects with TextKit Building User Interfaces in iOS7 Custom Transitions Using View Controllers Customizing Your App‚Äôs Appearance for iOS 7 Introduction to Sprite Kit Designing Games with Sprite Kit Getting Started with UIKit Dynamics What‚Äôs New in iOS User Interface Design Pretty much all the Whats New…

Continue Reading

Events & Reminders on iOS

  Many apps take advantage of the Events or Reminders on iOS. This is very useful when wanting to give the user the ability to add an event to the calendar or a reminder. This is quite simple to do, so let’s take a look. ¬†Create an NSObject Class to manage all our EventKit stuff and add the following: #import <EventKit/EventKit.h> @property (strong, readonly) EKEventStore *eventStore; @property (assign, readonly) BOOL eventAccess; @property (assign, readonly) BOOL reminderAccess; So far we are simply importing the EventKit, which by the way you must add as Link Library in Target Settings, Summary. ¬†Then we add a property to access the EventStore and some booleans.… Read More

Continue Reading

NSOperationQueue & NSInvocationOperation

1. In your main class’ init method call this: operationQueue = [[NSOperationQueue alloc]init]; [operationQueue setMaxConcurrentOperationCount:1]; 2. Then in your viewWillAppear you can call this: [self showLoadingIndicators]; //calls a method which presents loading indicators (optional) [self beginLoadingTwitterData]; // this is the method that fires it all off 3. In your beginLoadingTwitterData you call this: NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(synchronousLoadTwitterData) object:nil]; [operationQueue addOperation:operation]; // creates and adds NSOperation to a queue [operation release]; 4. In this synchronousLoadTwitterData is where you do the heavy lifting: NSDictionary *dict = [[NSDictionary alloc] initWithDictionary:[TwitterHelper fetchInfoForUsername:[twitterIds objectAtIndex:count]]] // this calls for a method “fetchInfoForUsername” which returns an NSDictionary, but to do so, it connects to… 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 App or Cocos2d Game Design – Grand Scheme

A lot of programmers that are entering the iOS application or Cocos2d game arena are somewhat confused about the overall scheme of things. They can’t see the forest for the trees. I’m a very visual learner myself, which actually makes me a rather bad programmer. Actually it makes me a bad programmer because I’m slow to pick stuff up. I need to see the big picture and then dive into the details, not the other way around. So I put together a simple image, for visual learners like myself, to understand how things operate. At this moment its a very simple image. I intend to update it constantly in order… Read More

Continue Reading

Library compile error in XCode 4.5 for iOS6 regarding armv7s and armv7

Here are the resources you will need to fix your libraries.a which are not compiling for armv7s, into working compiling libraries: The post on how to do it: http://www.galloway.me.uk/2012/09/hacking-up-an-armv7s-library/ An article on how to modify your $PATH on your mac:¬†http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable/ Another article on how to edit your .profile hidden file:¬†http://www.tech-recipes.com/rx/2618/os_x_easily_edit_hidden_configuration_files_with_textedit/ And this is the lowdown: You will basically have to create the .sh file & .c file mentioned in Matt’s post. ¬†He then explains how to compile the .c and chmod the .sh. Then you must add these files to your path by either creating a .profile or adding this line to your existing .profile: PATH=$PATH:$HOME/afolderwhereyouplacedyourabovefiles # Add to PATH… Read More

Continue Reading

NSOperation

Lets say you are not only downloading tweets (text) from the web, but actual chunks of raw data, such as images. You may have a method that returns a UIImage, such as: -(UIImage*)cachedImageForURL:(NSURL*)url{ //Preferably look for a cached image id cachedObject = [cachedImages objectForKey:url]; if (cachedObject == nil) { //set loading placeholder in our cache dict [cachedImages setObject:LoadingPlacedholder forKey:url]; //Create and queue a new image loading op ImageLoadingOp *operation = [[ImageLoadingOp alloc] initWithImageURL:url target:self action:@selector(didFinishLoadingImageWithResult:)]; [operationQueue addOperation:operation]; [operation release]; } else if(![cachedObject isKindOfClass:[UIImage class]]) { //were already loading the image, dont kick off another request cachedObject = nil; } return cachedObject; } Except notice this time the operation is not… Read More

Continue Reading

No free lunch…

I started coding in iOS since 2009. ¬†I do it part time because I have a full time job, so I dedicate about 3 hours a day, 5 days a week. I am a tech guy, always have been. ¬†Studied Biochemistry and picked up ASP, PHP and moved into iOS. ¬†But because I live in a country where technicians are highly undervalued, I got my MBA in 2000. ¬†So I know a thing or two about how to run a business. So when I started meeting indies in 2009, I approached them and said, “I have some ideas for an app, is anyone interested in working with me?”. ¬†Their response… 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

iOS Indie Developer/Programmer Evolution

These are just random thoughts on what I believe are the pros and cons of coding an app vs a game. ¬†The reason why I am writing this is actually because I find myself in the same predicament. ¬†I’ve been coding crap for the past 3 years and I believe its time to make something “significant”. At first I thought, I’ll code a bunch of apps and even though they might not be Top Pick apps, they will be enough. ¬†Even if they only make about $5-$10 a month, ¬†I may be reaping $100 a month which sounds cool. ¬†I even got into the whole iAds thing and thought it… Read More

Continue Reading

How to Read iOS or Mac OS Programming Documentation

The toughest part for me to get started was reading the Apple Documentation on iOS or MacOS. When I got into more APIs it got more complex. You need to understand how to read API or proprietary code documents in order to understand how to create a piece of code, connect to web services or debug changes in code. You will very often see the term DEPRECATED, which means a particular method name is no longer used. This is very important so let’s take a look at Apple Docs first: This tells us that the object of type NSArray has many methods that you can call on it. They may… Read More

Continue Reading

Passing Data Example

Delegates or Properties, take your pick. PROPERTIES Class A (ViewController) wants to communicate with Class B (ViewController) Before calling Class B, do the following: In Class B, create a @property NSString* receivedValue; In Class A, #import Class B then in the method that calls B (either prepareForSegue or didSelectRowAtIndexPath or some method where you present Class B view controller, do the following: Class B *calledVC = alloc/init calledVC.receivedValue = ‘whatever value you want to pass’; then call Class B VC Done!   DELEGATES Let’s say Class B wants to notify Class A that something has finished. ¬†In Class B add this above your @interface: @protocol YourDelegateProtocol <NSObject> – (void)itemWillBePassed; @end… Read More

Continue Reading

NSCoding & NSUserDefaults to store something simple…

Lets say you created an app which lets you select a person from the Address Book and you wish to set that person as the default user to use each time you launch the app. You want to store that preference in NSUserDefaults. If there is a lot of data to that person, you probably don’t want to store each key, key by key…This is where you can modify your NSObject class to conform to NSCoding and quickly save & load your data. 1. In you NSObject Class add theprotocol. @interface CustomObject : NSObject <NSCoding> 2. Now add these 2 methods to your NSObject Class: – (void) encodeWithCoder:(NSCoder*)encoder; – (id)… Read More

Continue Reading

How to mask a UIImage in iOS

– (void)viewDidLoad { [super viewDidLoad]; UIImage *imageToMask = [UIImage imageNamed:@”koko.jpg”]; UIImageView *imageToMaskImgView = [[UIImageView alloc] initWithImage:imageToMask]; CGRect imgRect = CGRectMake(0, 0, imageToMaskImgView.frame.size.width, imageToMaskImgView.frame.size.height); UIView *maskMaster = [[UIView alloc] initWithFrame:imgRect]; [maskMaster setBackgroundColor:[UIColor whiteColor]]; [maskMaster addSubview:imageToMaskImgView]; UIGraphicsBeginImageContext(maskMaster.bounds.size); [maskMaster.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSLog(@‚ÄĚ%@ is the view image‚ÄĚ, viewImage); UIImage *bFooImg = [UIImage imageNamed:@”blackapple.png”]; self.myPic.image = [self maskImage:bFooImg withMask:viewImage]; } – (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)maskImage { CGImageRef maskRef = maskImage.CGImage; CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef), CGImageGetHeight(maskRef), CGImageGetBitsPerComponent(maskRef), CGImageGetBitsPerPixel(maskRef), CGImageGetBytesPerRow(maskRef), CGImageGetDataProvider(maskRef), NULL, false); CGImageRef masked = CGImageCreateWithMask([image CGImage], mask); //memman CGImageRelease(mask); CGImageRelease(maskRef); return [UIImage imageWithCGImage:masked]; }

Continue Reading

AppleTV & AirPlay: The future

What can you do with your AppleTV? Aside from streaming movies or buying movies online instead of the limited selection at your local store, you can do much more than watch movies. In it you can access built in apps like YouTube, Netflix, iTunes, WSJ, Flickr, etc. you can play iOS “AirPlay-enabled games” and access the web with apps like these: http://theapple.tv/apps/list-of-airplay-enabled-apps/

Continue Reading

Use a simple NSNotificationCenter alert

The idea behind this is to notify one object/class of another object/class’ action. Thus you need the following: 1. A Class (A) whose object will register to receive notifications (be notified). 2. A Class (B) whose object will be doing something and when it finishes, must notify the other (post notification) Receiving Class A This class must cleanup its listening task so that when it is no longer active, the NSNotificationCenter will not waste time and resources notifying it about events it was once interested in. To do this simply add this to your dealloc method: //1. NSNotifCtr CLEANUP in viewDidUnload or dealloc [[NSNotificationCenter defaultCenter] removeObserver:self]; This class must actually… Read More

Continue Reading

Santiapps.com: Digital Graphic Design for newbies (noobs)

Wanted to share this tutorial for graphic design noobs that are interested in creating their own artwork for iOS games. You may indeed have some graphic design skills and some much better programming skills but turning your paper art into digital usable art is a whole new ballgame. Visit this tutorial in spanish, since this is a spanish blog: Diseno Grafico para Juegos Digitales (Principiantes)

Continue Reading

Android vs iOS

A friend of mine recently send me an email with this link from extremetech.com listing the 5 Android features that leave iOS in the dust. ¬†Here are my thoughts in response: 1. ¬†Homescreen/widgets. ¬†These drain battery life, which is why iOS doesnt have them. ¬†I’ve been learning to code in Android and their OS can run as many background services as apps that contain them. ¬†This drains battery and consumes bandwidth. iOS’s solution is APNS or push notifications which a server running on the internet can send to the device instead. ¬†Its not as fancy as Android, I agree, but ill trade it for battery life anyday. ¬†When hardware manufact… 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

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