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 ReadingCreating 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 ReadingCreating 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 ReadingiOS7 – 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 ReadingHow 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 ReadingStatic 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 ReadingCreating 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 ReadingWWDC 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 ReadingWatch this spider tweet
Watch this spider mor around the screen and tweet! Watch this #spider react to onscreen #Xcode #iOS #ObjC #indiedev http://t.co/Nt7BjFqR — marcio (@marciokoko) December 12, 2012
Continue ReadingGrandCentralDispatch & 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 ReadingLibrary 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 ReadingRandom yet helpful tips for Xcode 4.3.1
I’ve been learning a lot about tools for developing iOS apps and its amazing how much these tools, when you learn how to use them, can help you: Source Control Snippets Edit in Scope Speech Assistant Appirater TestFlight SDK Let’s look at these one by one: Source Control. This tool is for creating “Time Machine” like versions of your project as you progress through your project and make changes to it. The idea is two-fold: (a) Keep important subversions, i.e. version 1.0, 1.0.1, 1.0.5, 1.1.0 etc of your project as you make changes to it. And (b), share those versions with a team of developers so that you all have… Read More
Continue ReadingXCode & Git
Ok, i just started getting my feet wet in this but here is the scoop! Git is a versioning technology which allows you to create multiple versions of your project much like TimeMachine on your Mac. The whole point behind it is that at any time you can go back to a specific project mod and retake it from there. The first step is to GITTIFY your folder. You can either do this manually from the command line or from Xcode by creating a new project and check marking the Use Git Repository option. Since you are using Xcode simply check the box for Git in your new project. Now… Read More
Continue ReadingImporting Box2D & Chipmunk into XCode
am up to Chapter 13 and I have just finished RE-building my project because of minor details I may have omitted and Id like to share with you all and perhaps get cleared up: 1. Importing folders. When importing folders into Xcode, which Ive had experience with Coreplot, Facebook, twitter apis, json libraries and more recently Box2D and Chipmunk folders, there is a difference between copying and not copying if needed. I thought I understood the difference but Im not sure now. When adding a folder to your project, you add it via the finder first and then via Xcode. Lets take Chipmunk for example: a. You copy your Chipmunk… Read More
Continue ReadingPresence3: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 ReadingPlists, 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 ReadingStanford 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