Skip to main content


Showing posts from November, 2011

Xcode from scratch for scaredy cats: Sending a message to a method (NSLog)

Last time we saw how to set up a subclass and reuse the object. This time we're going to send a message to a method contained in a subclass and the subclass will vary its output based upon the variable contained within that message. I'm keeping things brief, and you'll need to recreate the 'New Project' and 'New File' elements by looking back at last time . This time, however, we'll make the new file a subclass of NSObject instead of UIView. This will mean we don't have "drawRect:" waiting for us to uncomment. So instead here is what your method looks like inside the subclass .m file: - (void)performOperation:(NSString *)operation { if ([(NSString *)operation isEqual:@"can you hear me?"]) { NSLog(@"Yes I can hear you!"); } else { NSLog(@"nope!"); }} And because this is a public method we'll need to add it to the .h file of the subclass with this line of code: - (void)performOperation:(NSString *)oper

Xcode from scratch for scaredy cats: Hello with a little class (UIView subclass)

This time we're going to do two things: (1) write some text (2) subclass this text so that we can reuse it. In order to do this first we need to create a new project entitled: "ALittleClass" using the same method outlined in the first ' Xcode from scratch for scaredy cats ' post. We are then going to create a "New File ..." within this project and call it "ALittleClass" When creating this new file you will be prompted first to choose a template - select iOS -> Cocoa Touch -> Objective-C Class followed by the Next button. You will then be asked to insert a filename beneath which is written - "Subclass of" - in this second box you need to select or type UIView and press enter. Inside the new .m file ("ALittleClass.m") you'll find some code that is "commented out". You need to remove the comments around this. So that it looks simply like this: - (void)drawRe

Error "Licensing has stopped working"

I recently encountered a permissions problem with Adobe CS3 running on OS X Lion, where  the error message that is at the head of this post appeared, and all programs in the suite refused to open. The first step instructed by the error message was to reinstall. This didn't resolve the issue, so I went trawling the Internet for a solution, and although Adobe has published  this near perfect guide to fixing the issue, I did find one error that had me stuck for a short while and thought worth reporting. It comes in point 3 under ' Solution 2: Run the License Repair Tool', where having downloaded  Adobe Licensing Repair Tool  you are instructed in sub-points (e-g) to open Terminal and drag there after starting Python and press return. This just threw up a syntax error for me. So instead of typing "sudo python", I just typed "python" at the prompt that appears after opening Terminal. And then, before pressing enter, I added

Xcode from scratch for scaredy cats: A slight return (if ... else)

In this post we return to the app that we built last time . The reason for this is that once we've pressed the button it doesn't do anything else, which is rather dull. In this post we'll change this, so that when we push the button again the background returns to white. The user then gets some feedback and recognition of subsequent button pushes. We'll be using the "if ... else" statement, which will be familiar to those of you who have experimented or worked with Javascript or PHP among other languages. If it isn't then don't worry as promised in the previous post we'll move slowly and simply. In order to insert the code we need to open our file called "PushButtonViewController.m" and scroll to the bottom of the file to our piece of code ("method") from last time: - (IBAction)sender:(id)sender { self.view.backgroundColor = [UIColor blueColor]; } and this needs to be entirely replaced by this code: - (IBAction)send

Xcode from scratch for scaredy cats: Push the button (IBAction)

(1) We're going to put to one side our "StaticImage.xcodeproj" for this post, but we will return to it in later posts, so don't trash it just yet. (2) Following the steps laid down in the first " Xcode from scratch for scaredy cats " post we are going to create a "New Project..." called "PushButton". (3) We are then going to navigate once again to the .xib file, this time called PushButtonViewController.xib ( if it is called ViewController.xib, or something else, then you forgot to type "PushButton" in the "Class Prefixes" box when you named the app ) (4) Now create a button by displaying the right-hand column of the Xcode application window and dragging it from the list of objects at the bottom of the column (as we did with an "Image View" in the first blogpost) (5) Next we need to select the "Navigate" menu from the top menu bar in Xcode, and from here click "Open in Assistant Editor&q