Saturday, May 26, 2007

The Demo Server

The demo server is almost up and ready to go! I'm using Google Pages to create it. I would highly recommend anyone to it. It's freaking awesome!

Anyway, here is the website.


Tuesday, May 22, 2007

CoreData and Objective-C


Here was my problem. I was trying to figure out the best way to store data in Objective-C. I know that Objective-C provides many ways to write text to a file, but handling relational structures can get tricky using this method. This is when I remembered CoreData. This was a little tricky to me at first but after thinking about it in a dumb way, I was able to figure it out. I guess I was looking at it way to much in detail, making it harder than it seemed. I have created an application that uses several features of Objective-C that I just barely figured out like the Alert Panel that is relative to the window that called it as well as getting data out of the array controller when you need it.

To download the application and source, click here and your browser will begin to download it from my iDisk.

Now, if you haven't used CoreData before, I suggest the apple developers website since they have videos :-)

When you have completed the video series (I think there are 14 two to three minute videos), you can then use my information to go in deeper with the CoreData stuff.

This is what I show you in my demonstration application:
  • How to access an array of information that is stored in the NSArrayController Object.

  • How to use the NSRunAlertPanel so that it drops down out of the window (The cool alert panel, I think ;-))
CoreData does all the hard work for you when it comes down to saving and loading information, but you can't do everything in the interface designer. Accessing the data in the ArrayController allows you to branch off and get even more creative with your applications without you having to manage data files.

I hope this makes someones day a little easier! It did mine... :-)

Thursday, May 10, 2007

Interface in Objective-C


I'm placing this post up because I just had an interview with Apple and I couldn't for the life of me remember what the definition to a interface was. I feel dumb because I talked to my roommate and described it perfectly. I hate it when I'm nervous.

An interface in Objective-C is like in the .h file. You have the interface that describes what the class looks like and provides the interaction with the class. Essentially, it is the interaction layer between two classes. Of course, when you think of it on a different scale, an interface could be anything that provides an interaction. Like the UI, it is an interface. It provides interaction. API (Application Programming Interface), It's another interface.

I have to remember this so if I get another interview I won't embarrass myself!

Monday, May 7, 2007

Key Press and Mouse Events in Objective-C

Okay, here is another situation that a programmer might have. Lets say, you are creating a drawing application that requires you to click and hold the mouse and drag it around the screen to draw a line. You can change the color by pressing a button on the keyboard, like b for black, r for red, g for green, etc... How would you go about doing that if the standard events in XCode don't allow for this...

This application is coming up next! I'm excited about this one simply because it will provide more control for you application.

Sunday, May 6, 2007

Recognizing a voice command (NSSpeechRecognizer) in Objective-C

Okay, Lets say you have a complicated application and you know you can do something in it but you cant remember how to get there. Standard UI rules state that you shouldn't overwhelm the user with controls and options. So, how do you help out the user? What about voice activated controls. Objective-C provides access to an object (NSSpeechRecognizer) that works with the computers voice recognizer to help you out. Just getting it to work is tricky.

So, here is the source code for the application. You can download it from my iDisk by clicking here.

I don't know how long this will be up. It all depends on when I get the actual server running. This is just a temporary thing.

For those who don't want to open the source code, here is how you get a NSSpeechRecognizer Object to work.

  • Instantiate your object
  • Set the Delegate to "self" in the INIT method of your control, like so:
    • [speechRecognizerObject setDelegate:SELF];
  • Create a delegate method (Essential, just put in this method header in your controls .m file)
    • - (void)speechRecognizer:(NSSpeechRecognizer *)sender didRecognizeCommand:(id)command{}
    • Fill in the blanks between the {}'s
  • As long as you have the delegate set to self, the object will look in the class where it is instantiate for that method. When a command is recognized, it will send it back in (id)command object.
    • Just so you know, it will only recognize a given set of commands. To set these commands, you will need to pass in a array of commands. I use a NSMutableArray to handle this. You can send in the commands using the [speechRecognizerObject setCommands:arrayOfCommands];
I know I'm going to have fun with this one.

I think I figured out through this demo app how to figure out if the mouse moves or not. It took me this application to fully realize how delegates worked in Objective-C.

Saturday, May 5, 2007

Demo Application Server

Would anyone like a demo application server? I'm going to be creating a web site here pretty quick (In about 2 months) and when I get it created, I can post up some zip files on the server with the source to the examples I post. I will also post the source to the examples I have now.

So, would anyone be interested? If so, comment on this with your thoughts.

I've been really busy this last week with LANDesk so I haven't had all the time I needed to get these demo apps created. I'm tring to get the time to continue working on them because it helps me out a lot. So, if y'all are still interested in my blog and my help with Objective-C, just subscribe to the RSS feed and it will notify you when a demo app is ready.