Monday, December 03, 2007

Thank you Developers from a Student

As finals are next week for me and I've finished all my work for 1 of my 5 classes this term and I am finally beginning to get some free time as I try and get my work done early, I thought I'd take some time out of my day quickly and express thanks to those developers who have made my life as a student on a Mac much easier. A BIG thank you goes out to Parallels who makes it possible for me to use Windows only when I absolutely have to ( my teachers haven't discovered I am using Pages or Textmate insead of Microsoft Word on Windows for most of my assignments yet ;) Thank you to Flying Meat! I had heard of VooDooPad but never really thought of using it till I had many classes this term all requiring a lot of note taking, so being the smart person I am I went right away to Flying meat and bought a copy to organize all my notes like so (and yes I misspelled Intro to Psychology I know, it was Day 1 and I had been up since 5AM) I can't count all the times I did group projects and I was the one who could always search through all my notes and always find that bit of info we needed to get our project done before the rest of class :D Another Thank you goes out to the OmniGroup for doing OmniFocus! Since I adopted GTD (Getting Things Done) and started testing the early Alphas and then bought an Educational OmniFocus license at the first chance I could, I've never been more organized and productive in my life! Turning anything that involves more than 1 action into a project and setting goals and due dates, as well as being able to add items into OmniFocus without actually having OmniFocus as the active app ( QuickEntry ) has probably saved me hours and hours of time. Thank you to the Vienna developers for making an RSS reader that's allows me to keep up to date on all my sites for tech news especially in my E-Commerce course. Thanks for Quicksilver! Probably my biggest productivity app period. This is the first app that I've used that I just have to have to multitask. Now every mac I touch I expect Quicksilver to be on there, and moan slightly if I discover it's not Thanks to TextMate and Apple (Xcode) for making my C/C++/Java classes much easier and more productive Thanks to Inquisitor (yes even on Leopard) for making my searching faster Thanks to Blizzard for World of Warcaft for giving me something to unwind from my homework on. Thanks to Unreal Tournament 2004 for another method of unwinding as well especially when Im on restrictive networks that won't allow me to run WoW Finally the biggest thank you to Apple for Mac OS X of course and everything from Spaces, Mail, Address Book, Time Machine, iCal, Safari, iTunes, iPhoto, Pages, Numbers, Keynote, Xcode, Instruments, Terminal, etc. Thanks for giving us developers a great platform & developer tools to develop these apps on! I never realized how heavily I depend on Apple and the various indie developers out there to make me productive till I looked back on this and past terms to see how much time I've saved in the process of using your apps. If I didn't have all this I'd probably be going raving mad right now or even worse... I'd be developing apps on Windows THANK YOU!!!

Monday, October 15, 2007

An Intro to Quartz and the Core Graphics API's (Updated Links)

Last week I gave a talk at the Des Moines CocoaHeads (Google Groups link) on how Quartz works in Cocoa and an intro to the C Based Core Graphics API's. Some of the topics I got started on was based off of Scott Stevenson's topics raised on Intro to Quartz Part I and II on Cocoa Dev Central and a couple of the Core Graphics examples were based off of samples from the Quartz book written by people in Apple. All in all the meeting covered the following * How Quartz does hardware accelerated drawing * When you would use Core Graphics API's over Cocoa's route to Quartz * A basic intro on to how views work * Basic Cocoa/Quartz Data Structures * Basic Core Graphics Data Structures * How coordinates in Views work * Cocoa Convenience Methods * How to draw Alpha (Transparency) * How paths, strokes and filling works * Using Images in your views * Using PDF's in your views * How to scale images/pdf's non/uniformly * A brief discussion on the Cocoa/Core Foundation Bridge * Places to learn about Quartz Additionally at the meeting we got into some small discussions on how Quartz works on a much deeper level, problems that arise during drawing with floating point widths, etc. The Keynote file from the presentation (for iWork 08) as well as a pdf from the keynote and all the source code examples are available for download below from the Des Moines CocoaHeads Google Groups page: Intro to Quartz Keynote Presentation Intro to Quartz Presentation (Compressed PDF form) Source code from projects demoed Update Updated links from Google Groups Page - if you can't download the files here they are located on the Des Moines Cocoaheads page @ http://groups.google.com/group/des-moines-cocoaheads

Wednesday, October 03, 2007

Des Moines CocoaHeads: All about Quartz

The next CocoaHeads meeting will be close to home in Ames @ Iowa State University. I will be giving a presentation about Quartz and specifically using it with Cocoa. Once the meeting is up I will post the Keynote presentation and source code so you can download it. Reposted from http://cocoaheads.org/us/DesMoinesIowa/index.html

The next CocoaHeads: Thursday October 11, 2007 07:00 PM CST at Howe Hall, Room 1246 - Iowa State University Campus. Directions: Howe Hall is located on the north-west corner of Bissell Rd and Marston Ct Ames, IA 50014 [map] "[Howe] is a big building, glass front, you can't miss it". Parking is available in lots north or south of Howe. [parking options] Agenda: Intro to Quartz: a discussion of the more advanced drawing routines available in Cocoa. And as always, general Cocoa geekyness.

Monday, September 10, 2007

Des Moines CocoaHeads in Ankeny & Contact Info

Info reposted from http://cocoaheads.org/us/DesMoinesIowa/index.html Schedule: The next CocoaHeads: Thursday September 13, 2007 07:00 PM CST at Kirkendall Public Library. Directions: 1210 NW Prairie Ridge Dr Ankeny, IA 50023 [map] Note that this is a new location as Panera was a bit noisy. Internet access is available, but the librarians tell me it can be "spotty" in the room we'll be in. Agenda: We'll be building a very basic app with XCode and Project Builder to get those who are a little green to the process some idea on how to start. This will undoubtedly progress into Advance tips and tricks as well as a discussion on Objective-C's finer points. We should also have time to discuss any issues people may be having or have overcome (I'm looking at you, Colin:) And as always, general Cocoa geekyness. You can also find the Des Moines CocoaHeads @ http://groups.google.com/group/des-moines-cocoaheads ============== Also wanted to let you know that i've setup a GMail account for e-mail regarding questions of things on this blog, general cocoa topics,etc. The address is on the sidebar to the right. You can email me at cocoasamurai@gmail.com.

Wednesday, August 22, 2007

An Open Letter to Apple

Every time Apple releases a new version of Mac OS X, Developers get shafted a little bit. We develop the apps that complement and enhance Mac OS X and make it great and what do we get for this? Releases of Mac OS X about a month after everybody else. It’s no secret that with paid ADC accounts we get a free copy of Mac OS X as it’s stated clearly on the ADC Site ( http://developer.apple.com/products/ ), which is why anybody who knows they are getting a free copy wouldn’t buy one. Well I am not here to endlessly bitch about it, I am here to provide an easy to implement solution... certificates. I propose instead of letting developers sit by waiting for Leopard to come a month late and let everybody else get a copy of Mac OS X Leopard when it comes out right away, let developers sign up on the ADC site for certificates for a specific Apple store if you want it. Instead of mass mailing out these certificates to every developer (wether they will be at a Apple store or not, thus potentially leading to some abuse of the system) open a form on the ADC site that checks our credentials (knowing if we have an account with a free copy of Mac OS X (Select, Premier or Student ) or not), and then lets say the form can contain the Apple Store we plan to go to and then give us a printable (or mailed to us) certificate that when we go to the Apple store on Leopards launch date we can redeem for a copy of Leopard. I am guessing that due to the close time frame of Leopard in October it’s probably too late to create this so that certificates are mailed to us. So I suggest this

  1. Create a Section on the ADC site that lets developers sign up for a printable certificate (optionally with a serial code pattern unique to the particular apple store) to be redeemed at a specific Apple Store for Mac OS X Leopard
  2. This form validates our ADC account and when it’s all submitted sends this information to the specific Apple store. 
  3. When Mac OS X Leopard launches developers print this certificate out and go to the Apple store
  4. When at the apple store the employees scan a barcode on the certificate or enter in some unique serial number/code and in combination with a simple thing like our drivers license for ID, validates us and takes the full price off of leopard and thus developers get a copy of Mac OS X 10.5 Leopard! :D
Thus Developers are happy! We get Mac OS X Leopard at the same time as everybody else, like it should be, and don’t have to wait a month to get it in the mail. Everybody wins! I realize that perhaps I haven’t thought every detail of this out, but it seems entirely plausible to me to have some system in place so developers who are genuinely entitled to a free copy of Mac OS X because of their paid ADC account can go to the Apple Store and pick up a copy the same day as everybody else. Heck I’d pay a small fee for the convenience of picking it up the same day as everybody else. Like I said this is just a suggestion, but I think as a developer instead of endlessly complaining about it we should put forward solutions to this problem and appropriately communicate them to Apple. The main reason I post this here is because I think there needs to be some open debate about this long before Apple publishes Leopard and we hear the moans of developers waiting for their copy of Mac OS X to arrive, the only alternative to this that I can see at the moment is for Apple to mail our copies of Mac OS X to us early (but then they could not really ensure AFAIK that the mail system only delivers them to us on the appropriate date all at once.) What does everybody else think about this?

Wednesday, July 18, 2007

CocoaHeads starting up in Des Moines!

Bout time! :D The first meeting of CocoaHeads chapter in Des Moines, Iowa is starting up. Im planning on attending and if your in the area come on by! When: August 2 @ 7-9pm Where: Panera Bread on 86th in Urbandale Google Maps Link Why: Meet local Cocoa developers like you who want to know more about Cocoa and voice your opinion about what you'd like to learn about in future meetings

Thursday, June 07, 2007

Make the most of your time @ WWDC

Well I am not going to WWDC this time around. But chances are if you are reading this you are... or at least you just wanna know what all the fuss is about. Scott Stevenson posted his thoughts on CocoaDevCentral and as a first time attendee I thought i’d give you some tips from things I learned at WWDC 06. Students Generally speaking students get the Sunday before the Keynote to go through a few general sessions by some guest speakers, followed by a Dinner and Job Fair. But lets get the ugly out of the way. Get there Saturday with a good amount of time to get the lay of the land. I don’t know about WWDC 07 but in 2006 the Student session was at a hotel and not at the Moscone center. So you’ll need to know where the student session is at and how to get there. If you can print out as many copies of your resume (assuming your going to the career fair) before leaving on the trip, or find a copy place on Saturday and save yourself some time. You should have a good amount of time on Sunday before the career fair to do this, but I would rather have spent the time relaxing. Also you’ll need to get your badge you wear all around WWDC on Saturday at the Student Registration. You can always get this later, but I would really recommend getting your badge on Saturday. When you start out Student Sunday feel free to bring your MacBook/Pro to take notes, etc. Then you’ll have your sessions as well as lunch then the Career Fair. Many students ask about the attire you wear to the career fair. In general most people going wear formal clothes, but you are totally free to chose what you want. Your not required to go formal. The Keynote and First Day Again for the rest of the WWDC attendees, get your badges ahead of time before Monday. Just trust me, it’ll save you lots of time and effort later on. Scott was right about the Keynote comparison between WWDC and MacWorld. I woke up at 6 am and got there 7 am and the line was from the front of the building and wrapped around roughly a block. When I finally got in to the keynote room, I got a spot only a few rows back from the frontmost spot the average attendee could get. In comparison I read about how people camped out the night before MacWorld. Overall get there at whatever time you want, but if you want a really good spot then get there at around 6-7 am, if you want any decent spot I wouldn’t get there more than a couple hours after that. Then you can watch the keynote and break for lunch. After that you’ll go through a couple State of the Union sessions followed by dinner at a reception there. The Sessions Apple makes a list of sessions available ahead of time, but many of them are blank for unannounced sessions. All I can offer you here is mark out which sessions you’d like to go to ahead of time. When they finally do announce all the sessions, all you need to do is compare your selection against the newly announced sessions and make your choice. You can always go for a session in something your interested in learning vs learning how something has improved in the next Mac OS. Personally i’d always go for something new if you can as they paid off big for me, but again it’s all your choice. If say your job revolves around some particular feature/topic then certainly go to the sessions on that. You can always watch the video of the session later on. Hands on Sessions Whereas most sessions are like listening to a lecture/guide to how something works, the hands on sessions are more tutorial-like than anything else. The one hand on session I went to was nice, but at the same time it’s wasn’t required you even follow along to enjoy it. Apple will probably provide code ahead of time on the WWDC attendee site. If you are even thinking of going to these sessions I’d personally take the time and download the code/files for the sessions ahead of time so you have them in case you go to the session. Labs Labs are a nice time to get some one on one time with apple engineers to get answers to your tough problems. If you intend to go to these have your laptop with you and a list of things you are trying to get help on. In many sessions you are attending you should pay attention to any mentions of specific times for a lab on that subject so that you can make the maximum use of your time at WWDC. Feedback Forums Feedback Forums are a very loosely structured meeting. Basically key people from Apple that work on whatever the forum is focused on are on stage and take your feedback on that subject wether it’s good or bad, or if you just want to offer advice on things you think apple really needs to include/improve in whatever the forum is focused on. These sessions are ok, but aren’t really that useful to you unless you really want to give apple some feedback. Special Events There are 3 special events definitely worth attending at WWDC. The first being the Apple Design Awards where developers get recognized for producing some amazing apps. Each time this is held the competition keeps growing in size. The other event is stump the experts. This one is an event they even encourage you to take all the pictures you want. It’s overall a very good time to be had trying to solve the puzzles they put up and all the questions. Too bad theres no video of this on the ADC on iTunes. The last event is the Bash on Apples Campus. If you want to get a decent spot, be sure to line up early. Me and my friends did and we got to be among the first to get in line for the Apple Store there and it still took a while to get in there. If you get there and see a long line it may not be worth it to even try and get in. They have plenty of food and drinks there as well as a musical guest of some sort. WWDC 06 featured a DJ, it sounds like 05 featured a band ( Jimmy Eat World.) Meals Everyday Apple has Breakfast and Lunch for all attendees as well as dinner on a few nights. It seemed to me that there was generally plenty to eat there at any given time. There was even enough laying around just before the keynote to make a decent breakfast. As for lunch, I can’t speak to everybody’s taste, but I found there was a decent variety. Usually there are a few options at any meal and I believe there was some vegetarian meals, but I didn’t pay much attention to them while I was there. As always there are options for meals around you in San Francisco, but mostly they seem a bit expensive and so most of my meals were at the Moscone Center.Also there is always (and I mean ALWAYS) a ton of free drinks in the commons area of each floor (except the 1st floor.) By drinks I mean lemonade, water, etc. Overall Overall just relax and have a good time there. Unless you really need help at the labs with specific topics just go with what seems interesting to you and never second guess yourself, you can always watch the video of the session you couldn’t go to later on when Apple puts it up for download on iTunes. Enjoy yourself at WWDC! Also let me know if there was anything else you thought was important from your experiences at WWDC.

Monday, June 04, 2007

OMG iPhone SDK!!!

Well the Mac News & Rumor sites are abuzz with news of a potential iPhone SDK at WWDC 07. Personally I never know what to trust when these types of rumors come out. I do believe though that there is usually an element of truth behind the rumors. Since writing my original iPhone SDK analysis shortly after Steve’s keynote i’ve had some time to reflect on this and I must say I still stand by it. To quickly recap here are some observations I made

  • There are no Windows in the iPhone, the entire system appears to revolve around presenting and animating views
  • The sheets that animate onto existing views appear to only come from the bottom-up as seen in the keynote
  • all views and layers appear to have the ability to become partially transparent including the toolbars and topmost statusbar
  • The iPhone shows the same cocoa controls we know with some sporting some theming to blend in with
  • the iPhone UI, these controls include NSButton, NSSegmentedControl, NSSearchField, NSToolbar, etc
  • The keyboard sheet will probably be a standard sheet you can call for input from any app, gone will be the days where we simply assume users can type something at any time
If the iPhone SDK does actually show up at WWDC then many questions developers have been curious about will finally be answered. Apple likes to keep their apps short and simple, especially on the iPhone so it makes it difficult to try and predict the full range of such a SDK. John Gruber thought that the iPhone SDK would simply take time to document before it could be released to developers and thus the comments made by Steve Jobs are simply just irrelevant and hide the fact that they may still be preparing the SDK for public consumption, a thought seconded by boredzo. Which makes sense to me, after all the reporters who managed to get some play time with the iPhone after the keynote stated that at some points they thought they broke the iPhone because no controls responded and found out that what they were looking at was only an image instead of some finished apps. Even if software was finished there it would still take some time to document to any decent degree. Something Im surprised that’s never been mentioned anywhere is a good theory for how to develop software for the iPhone. After all gone will be the days of a single toolbar, one mouse, a floating palette, etc. This isn’t Windows Mobile, this is Mac OS X Mobile dammit! Where are the big discussions at? Even in the absence of a official SDK, we could all make some general assumptions and guidelines with the views, and buttons we saw in the keynote alone. Maybe a better question is that if the Windows Mobile based phones suck so much what can we learn NOT to do from them? Unfortunately this is something I feel I can’t adequately answer here as i’ve never used a smart-phone with windows mobile yet, the best phone I’ve owned so far is my current Motorola RAZR V3m that’s been locked down by verizon. Thankfully it syncs with iSync, or I should say did. It now experiences bugs syncing and forces me to go from syncing once a month to once every couple weeks due to a stupid calendar issue of some sort. In any case every phone I’ve ever used has utterly sucked in my opinion. Entering alarm times, looking up events in my calendar all utterly suck and the fact that Verizon has locked it down doesn’t help at all. Another thing that people haven’t explicitly discussed is the impact of some particular features in the iPhone on the SDK. If the iPhone has Core Animation then it should be generally assumed that it’s based off of Mac OS X 10.5 Leopard unless apple did a major job of back porting Core Animation to 10.4 Tiger which I very much doubt. So that also means we also have garbage collection which makes a lot of sense for the iPhone as it won’t exactly be an expandable environment. Some developers have been wondering about how we handle the multiple mouses thing. Personally Im not worried about simple operations such as zooming in views. I think that may be handled by simply having your view do drawing triggered by delegate methods. What Im wondering is things like how we track the changes on the UI by 2 mouses, like if we have 2 sliders and the user decides to operate on both of them at the same time. Or can I use 1 mouse to let a user browse a list and another one to trigger that list to scroll faster/more slowly,etc? A point brought up by comments on the previous iPhone article thought several things might happen for the developer tools like anything from a whole new Xcode to just a simple iPhone emulation app. Personally I’m going with the 2nd option. I think it wouldn’t be in Apples interest to create a whole Xcode for the iPhone, but rather to create an iPhone project category and to possibly limit what you can do in Interface Builder under this special mode. Lastly one BIG thing nobody’s mentioned is that this SDK may be very limited at first. If the SDK is presumed to work with Leopard features, then that should limit running the iPhone SDK to Leopard as well under a...oh say new beta of leopard distributed at WWDC. Overall I’ll say this. I don’t think it’s outside the range of possibility to see an iPhone SDK introduced at WWDC or at the very least to see one announced and shipped later on after WWDC. I have the day off work for Steve Jobs keynote and unfortunately I am not going to WWDC so I will have to watch the feeds same as many of you.

Tuesday, May 01, 2007

Wahoo! Finals are over! :: Book & QuietLog

Finals are finally done with, all my big projects are over with, all my homework is turned in I can refocus all my energy again!!! :D Don't' get me wrong I like learning in detail about algorithms and some finite math, but after a few months of doing big projects it gets tiring very fast. Most importantly im gonna get back on track on writing here regularly. Advanced Cocoa Book I don't usually give my thumbs up to something that I haven't completely gone through yet, but i've gotten about halfway through Aaron Hillegass and Mark Dalrymple's Advanced Mac OS X Programming and already I love the book. It's the first Mac Developer book I've personally read that doesn't treat you like a complete newbie to Macintosh Development and instead shows in great detail how Mac OS X works and will even show you some nice unix tools you didn't know existed that can actually be of great help to you. The book covers various topics such as Multi-threading, Interprocess Communication, Networking, Performance Tuning, kqueues, Bonjour, Authentication, Keychain, GCC, GDB, memory management, etc. Really this book is a fantastic book that I would really recommend to all Mac developers out there. It starts you right off showing you in detail how you can work with gcc then goes into libraries, gdb, memory and more. Thank you Aaron and Mark for putting together such a great book! QuietLog I also wanted to share something with you that I posted in my personal blog a while ago and recently I've learned it's value as I begin to really use it in my serious projects. And I found it on Borkwares quickies site. To be honest I'm not sure how I came across Borkwares quickies site but I'm glad I found it, if you haven't been there take a minute and open up another tab and go there after you see this. One problem I have with NSLog is that it can provide you with a ton of information when you just want to print simple statements. Printf can be useful, but it can't handle Objective-C objects. So that's what QuietLog is for...

void QuietLog (NSString *format, ...) { // get a reference to the arguments on the stack that follow // the format paramter va_list argList; va_start (argList, format); // NSString luckily provides us with this handy method which // will do all the work for us, including %@ NSString *string; string = [[NSString alloc] initWithFormat: format arguments: argList]; va_end (argList); // send it to standard out. printf ("%s\n", [string UTF8String]); [string release]; } // QuietLog
It's a nice method that can handle objective-c objects and print them out in a simple manner, you won't notice any difference except the all the preceeding junk you didn't care about. To implement this in a way you can use throughout all your project you just need to do it like so... QuietLog.h
#import < Cocoa/Cocoa.h > extern void QuietLog (NSString *format, ...);
QuietLog.m
#import "QuietLog.h" void QuietLog (NSString *format, ...) { // get a reference to the arguments on the stack that follow // the format paramter va_list argList; va_start (argList, format); // NSString luckily provides us with this handy method which // will do all the work for us, including %@ NSString *string; string = [[NSString alloc] initWithFormat: format arguments: argList]; va_end (argList); // send it to standard out. printf ("%s\n", [string UTF8String]); [string release]; }
And then import the QuietLog.h anywhere you actually need it and now you have a nice utility to use in your projects. If your curious about the va_* stuff you can find more info here http://www.delorie.com/gnu/docs/glibc/libc_675.html, the va_list is a type that's part of the GNU C Library for obtaining info about the arguments used in calling the method. I could go on more about this but you can read the GNU page if you want to know more about it. Thats it for now. I have some free time now that I have roughly a month free from school and can work on my new pet project RedFlag (hopefully to be a great and elegant Del.icio.us client) and post some more great stuff I've discovered. See you soon! :D

Sunday, February 25, 2007

F-Script : Part I - Introduction

Man it's been a while since i've last posted and im really sorry for that. Anyway i've been starting on a 2nd Open Source Project I call Red Flag (name is meant to be a joke at the stereotype that Open Source is Socialist/Communist) which is going to be a Del.icio.us client for Mac OS X that offers more organizational and browsing abilities than Cocoalicious offers. I like Cocoalicious, I just want to do more with my bookmarks on a native Mac OS X Client. Plus school has been a bit more work than I thought at times, because as much as I love my Data Structures with Java course it can be a time consumer sometimes. And for those who took a look at my personal blog, no World of Warcraft hasn't drained huge amounts of time from me preventing me from doing this.. just so you know. Im doing great now. Anyway onto the topic at hand. If you haven't heard of F-Script you really should take a look at it as it can help you in many situations. I must admit I haven't been using it for long, but already what i've seen has impressed me. I was introduced to F-Script at WWDC 06 and thought it was something interesting but didn't pick it up till about a month ago. First in a nutshell (quoting Wikipedia) F-Script is

F-Script is an object-oriented scripting programming language developed by Philippe Mougin. In a nutshell, F-Script is Smalltalk with support for Array programming.
What does that mean? Well F-Script can do many things. You can use it to create small test apps on the fly, you can take control of your app at run time and browse the state of various objects without using Xcode, the debugger, special frameworks,etc. You can do various tests in F-Scripts stand alone console. Additionally F-Script is Open Source licenced under the BSD license. Syntax First off I should show you what's different between F-Script Syntax and regular Objective-C Braces... Objective-C
*color1 = [NSColor blueColor];
F-Script
color1 := NSColor blueColor
As you can see F-Script doesn't use the Objective-C braces Strings F-Script using single quotes for strings instead of Objective-C's @"". Example Objective-C
NSString *string1 = [NSString stringWithString:@"This is a standard string"];
F-Script
string1 := NSString stringWithString:'This is a standard string'
Assignment As you've noticed above F-Script doesn't use a simple "=" for it's assignment operator it instead uses the colon equals ":=" ie Objective-C
color1 = [NSColor blueColor];
F-Script
color1 := NSColor blueColor
Types Lastly you should have noticed that none of the F-Script examples had a type declaration on them. That's because everything in F-Script is of the type id which is to say everything is a generic object. Basic F-Script Components Well when your first starting out with F-Script there are 2 components your primarily concerned about. F-Script Anywhere F-Script anywhere is the app you'll use to begin out using F-Script with your app. It launches with a list of open applications and uses mach inject to add a FSA menu to your application which (of course) stands for F-Script Anywhere. To do this simply launch F-Script Anywhere and click on the running application that you want to with with in F-Script in the table and click Install. If it's successful then you'll see a check mark by the application. Warning! I should warn you that doing this can crash the running application so do this with some caution. In my many times of doing this i've only experienced 1 crash so far, but as always your mileage may vary. After doing that you'll now see a FSA menu in your app! With that menu you can launch a F-Script console for your application and begin to start playing around with your app in F-Scipt. F-Script This admittedly is the application I haven't played a lot with on it's own, but really should play with more. F-Script is a standalone console and browser workspace for playing around with F-Script without piggybacking onto a running application. From here you can play around with various things in F-Script if you just want to play around with learning F-Script's syntax or you can even do things like create a window with various objects that perform various actions. Yes you can create a application with F-Script and change things on the fly! In fact here is a example that comes with F-Script that implements the Currency Converter application Apple provides a tutorial for, but done in F-Script.
"F-SCRIPT CURRENCY CONVERTER (VERSION 1)" "Instantiate and configure a window" window := NSWindow alloc initWithContentRect:(125<>513 extent:383<>175) styleMask:NSTitledWindowMask + NSClosableWindowMask + NSMiniaturizableWindowMask backing:NSBackingStoreBuffered defer:NO. "Put the window onscreen" window orderFront:nil. "Give a title to the window" window setTitle:'Currency Converter'. "Instantiate a form object" form := NSForm alloc initWithFrame:(15<>70 extent:348<>85). "Put the form into the window" window contentView addSubview:form. "Configure the form" form addEntry:'Exchange Rate per $1'. form addEntry:'Dollars to Convert'. form addEntry:'Amount in Other Currency'. form setInterlineSpacing:9. form setAutosizesCells:YES. "Instantiate a decorative line and put it in the window" line := NSBox alloc initWithFrame:(15<>59 extent:353<>2). window contentView addSubview:line. "Instantiate a button, put it in the window and configure it" button := NSButton alloc initWithFrame:(247<>15 extent:90<>30). window contentView addSubview:button. button setBezelStyle:NSRoundedBezelStyle. button setTitle:'Convert'. button setKeyEquivalent:'\r'. "Create the script that will compute the currency conversion" conversionScript := [(form cellAtIndex:2) setStringValue:(form cellAtIndex:0) floatValue * (form cellAtIndex:1) floatValue]. "Make the script the target of the form. The script will be evaluated when the user presses Return" form setTarget:conversionScript. form setAction:#value. "Make the script the target of the button. The script will be evaluated when the user presses the button" button setTarget:conversionScript. button setAction:#value.
What's great about this console is that is also comes with excellent code completion. My only complaint is that it doesn't filter on the fly like Xcode, but it's definitely a step up from other code completion systems out there. All you need to do is hit escape and it'll start showing you the available options. F-Script and your App F-Script is great for exploring the state of your application as it's running and being able to very flexibly change things. I'll show you better examples in latter parts of this tutorial series, but for now i'll show you a simple thing F-Script Anywhere can do. For this example I'll use my app AssignmentTracker X, but you can do this with any app. I start out by launching AssignmentTracker X then installing the FSA menu. After that's done go to the FSA menu and click on the "Browser for Target..." menu option. Then you'll get a special cursor which you can use to click on a view in your app. In this case im clicking on the RoundedBox view which shows the Assignment Detail in my app. After doing that you'll get a list of the views you can inspect. In my case I selected the RoundedBox option (RoundedBox is a NSBox subview so you'll probably select NSBox if your using another app.) When you do this you'll get a browser which shows all the information about it. Now to start off im just gonna show you something simple... changing the title of a view. I start out by searching for the method "setString" in the search box on the upper right hand corner. Then click on the setTitle method in the first column of the browser view, a sheet will drop down with the argument to send with the setTitle method. I type in 'Something Else' and hit Enter. Now before the title of the RoundedBox option was "Assignment Detail" but now it's "Something Else" We did this without modifying the Nib, programmically changing it or even touching Xcode at all!!! Conclusion So what did we do here?
  • We got a basic intro to what F-Script is
  • We saw the basic differences between F-Scripts syntax and Objective-C's
  • We learned basic information about F-Scipts 2 major components ( F-Script Anywhere and the F-Script console)
  • We learned how to change the state of an object on the fly
More on F-Script Part 2 I've just scratched the surface on what F-Script can do here. I'll show you more F-Script tips & tricks and see some other practical examples of what F-Script can do in the next article! Until then just download F-Script and play around with it!

Sunday, January 21, 2007

How I think iPhone software works

As I am finishing up my other article I thought id take on a challenge and do what nobody has done yet in doing an in depth analysis of the iPhone software and what it'd take to develop for it should Apple ever allow it. Hey I am up for a good challenge Ok lets get off on even ground here and briefly cover what Apple has said about the iPhone and Mac OS X on it.

  • The iPhone will use a touch screen which leaves it dependent on good touch detection software
  • touch screen for controls, ignores unintended touches, multi-finger touches for controls
  • iPhone runs Mac OS X (albeit a stripped down version) with Syncing, Networking, Multi-tasking, Low Power (power management), security, video, Cocoa, Core Animation, Graphics, Audio
  • Proximity Sensor to detect when objects are near (ie taking a call)
  • Ambient Light Sensor
  • Accelerometer (for detecting when you've switched from portrait to landscape)
Now I could go over all the features, but then that would be beating this subject to death, instead I intend to focus on the software side of this and give answers to things like keeping track of multiple mouses, user interfaces, etc. Mac OS X OK, well one thing that's been stated is that the iPhone runs Mac OS X or OS X. Some people have tried to prove that this isn't the case, but as has been pointed out Apple controls the licensing for Darwin and thus can change the license and port the kernel and software to whatever platform they want to. I haven't studied the XNU kenrel and Darwin in depth, but we can assume that Apple started out by porting Darwin to the ARM processor assuming that's what the iPhone runs on. So they start out with Darwin then probably went through a similar process of
  • Added necessary Drivers for the iPhone hardware
  • Added necessary utilities for Syncing, Networking, Power Management, Graphics, Audio
  • Added Mac OS X Frameworks Cocoa, Core Animation, etc.
  • Heavily modified the UI to System to display windows, dialog boxes, etc differently for this smaller interface and created the iPhone SDK
  • Wrote a new login sequence to deal with the touch sliding login
  • Wrote a Menu screen to show all the apps and have the dock-like app selection at the bottom
  • Wrote the iPhone apps
The iPhone Apps When I looked at the iphone apps I noticed several things
  • The iPhone shows the same cocoa controls we know with some sporting some theming to blend in with the iPhone UI, these controls include NSButton, NSSegmentedControl, NSSearchField, NSToolbar, etc
  • They all have a top window toolbar and some have a bottom window toolbar that are the same size across the apps (with the exception of Safari allowing a little bit more space at the top for displaying a web page title which suggests they are expandable in size (at least to a degree)). The toolbars appear to be either a grayish blue color or a glossy black with the ability to set the opacity for both the top and bottom toolbars as demonstrated in the Photo app (even the topmost status bar also appears to be able to have it's opacity set as well)
  • All sheets that slide in animated onto an existing view come up from the bottom vs dropping down from the top like on the Mac OS X we use currently, all views appear to slide up from the bottom as well.
  • Im guessing the keyboard view that pops up is probably something that any app can call and use with the app (like Font Dialog, Color Dialog, etc.)
  • There is no dark grey / light grey repeating background pattern anywhere in the UI like in the standard Mac OS X default background. The UI is entirely solid colors or gradient patterns.
  • The New way to build Apps on the iPhone Clearly instead of heavily modifying an existing interface it’s clear that the iPhones approach is a brand new method all together. We can all clearly see that there are no “windows” in this approach, but rather views and ways of switching between views. In the same way that when an app launches on Mac OS X it has a main window that is spawned, the apps on the iPhone has a primary view that is displayed. Clearly in a device such as this your app needs to be very simplistic and get straight to the point of the app right away without cluttering the screen. Another thing to take into consideration are the fonts. In addition to have a very small screen to work with, the fonts on everything are bigger than you’d be used to in developing Cocoa apps on Mac OS X. Many controls and labels shown have bolded fonts, typically these controls appear to be the ones displaying what view your actually in (for ex a label saying Favorites to display that you are in your favorite contacts,etc) while secondary controls actually appear to have a very small, but readable, font. The Screen is another thing to take into consideration. Clearly whoever is using the iPhone can switch the view from portrait to landscape at anytime so your app needs to take advantage of that. Im guessing here 1 of 2 things happens (1) Nothing happens - your view is simply resized and draws again in a different frame size (2) Your app implements a method to do something different when the orientation is changed so you can do something special if need be and is implemented something like
    - (void) orientationChangedToLandscape: (NSEvent *)event; - (void) orientationChangedToPortrait: (NSEvent *)event;
    or
    - (void) orientationChanged: (NSEvent *)event { if([NSOrientationCenter viewOrientation] == NSPortraitOrientation) { //we changed to portrait } else { //we changed to landscape } }
    though I think the first example is the much more likely. So lets explore some theoretical iPhone apps! From all appearances when you begin creating an iPhone app you have the entire screen, minus the top status bar, to work with. As you’ve undoubtedly seen by now we have a lot of vertical space to work with and not so much horizontal space. This entirely rules out sidebars as it’d take up way to much horizontal space and most likely waste some good screen real estate. We’ve even seen some controls such as NSBrowser have their functionality changed entirely as instead of having several columns visible on the screen at once we only have one and switch between them. So what should we build? Lets build a simple notes application. Now the iPhone already has this, but i’ve never seen it demonstrated or seen any screenshots of it. I chose this because this demonstrates many of the aspects of all apps (with the exception of music) as shown in the keynote. Now we may want to put a ton of options in this app, but we really need to plan this out well. So what are the critical functions we need to get out on the first view? In this case I decided to go with 2 toolbars and a content area containing a list of the notes. Here we did a lot with a little. We implemented the following functions (1) Ability to add notes (2) Ability to delete notes from list (via edit button, i’d have a minus icon appear by the title and if they want to edit they click the title or if they want to delete hit the minus icon by the title) (3) Ability to edit notes (4) Ability to sort notes Not much to it and i think that’s about all we can do with this space, anything more and we’d probably begin to clutter up the screen. And that’s the way we need to think when designing an app. When you click a title of a note we have another view come onto screen via some sort of Core Animation transition. I’d assume we could swipe over to a view containing something very similar to the e-mail app with a title field and a notes text field. Very Simple. The only thing unclear here is how we designate a new view to be the primary content view and how we switch between them through core animation. Does each app have some sort of controller with a pointer to the primary view and when we want to switch we do it like [self transitionToView:(NSView *)newView viaCoreAnimationType: ... or something all together different? Multiple Mouses oh my! Now much has been discussed about the multiple mouses aka multi finger gestures as seen in “this pinch” when steve jobs used the gesture to zoom in and out of a photo view. I personally didn’t think this would be very hard to deal with and this is why. The operating system is aware that multiple contact points could be used as mouses. Presumably this has a limit of 2, though we don’t know this for sure. However when I watched the demo I noticed that by far the 2 common things steve did was (1) slide fingers across the screen (2) tap controls on screen We can use “the pinch” though the only apps that used that was the photo viewing app and Safari. However lets say we want to use “the pinch" for something, in this case we may want to make a better photo viewer app or just anything that we’d need to zoom in on something. Based on the keynote here is how i think it works (1) Two contact points are made (2) At this point the distance between them could be measured and a notification may be sent to the view telling it to prepare for zooming or the 2 points could be used as points to create a frame reference on the image or view (3) When the user moves the fingers a notification is sent to the view and the view is then zoomed in or out so the points on the first frame match the points as they are currently This diagram isn’t an exact match in terms of zooming in, but you get the idea. In order for any app to deal with this well it needs (1) To be notified when 2 contact points are made (2) To be notified at an interval as the resizing is happening so the view can redraw appropriately (3) To be notified when the resizing stops One interesting thing I saw was that (as far as I could tell) the photo view didn’t need to pause and adjust the image on the fly as seen in iPhoto, that is during resizing the photo didn’t get pixelated and then adjust and smooth out the image when the resizing stopped. Beyond this we don’t know if the iPhone is capable of recognizing other gestures. Can it recognize circles for instance? I know mockups of the true full screen ipod had this, but the demo only showed sliding gestures. It’ll be interesting to see the range of gestures the iPhone is capable of when it comes out. Conclusions Clearly the iPhone is a totally different environment than has ever been presented before. Instead of windows we have views and switching between the views via Core Animation. As this is not open we really have no idea of how things work right now, but based on how Cocoa and Core Animation work currently we can make some good educated guesses. It’s clear that in order to make good apps for this device we may not be able to use all the NSControls and those that we can use right now and we may not be able to use them in the same ways we use them on Mac apps right now. I would have to think that even though Apple has said we will not be able to put our own apps on there, someone probably will hack the iPhone and find a way to put apps on there. After all the apps on there can’t be written in stone, Steve Jobs himself implied they put the touch screen there so that they can update the apps in the future and implement new ones if need be. There are many unanswered questions like if someone hits the home button while doing something in the middle of an app and you go back to the original app do you go to where you left off or the primary (first seen) view? Can the apps themselves set this behavior? Are we using Xcode and Interface Builder to create these iPhone apps or some tool altogether different? Do you have to run the apps on the iPhone or is there some emulation environment to test them in? I may think that it may be possible to code the iPhone apps in Xcode, but for designing the UI and testing them it may require something unique as I think compiling a project then uploading the app to the iPhone each time you wanted to run the apps would drive you insane. In the end all of this is really just my best guess, I could wake up tomorrow and realize that part of this is totally wrong, I could just be full of it. What do you think?

Thursday, January 18, 2007

I've finally joined the Macintel crowd

Well it had to happen at some point and while I would have liked to have done this much sooner than later, but I finally got my Core 2 Duo MacBook Pro and have finally got my hands on the Beta of Parallels which im using now to run Windows XP for school so I can get rid of my HP Laptop once and for all. Coming from a 1.25Ghz PowerBook G4 this thing is blazingly fast and I love finally having an iSight. I only have my old powerbook around for a little bit longer till I'm sure I have everything and then put it up for sale. In the mean time every time I switch over to a new primary Mac I keep forgetting how much work it is to get everything back to normal. All your apps, preferences, tweaks and customization you do doesn't seem like a lot till you start with a blank slate. In any case the lesson here is School Windows requirements for classes are a great excuse to get a new Intel Mac :D Macworld and the iPhone Macworld was both great and disappointing. While I know everybody seemed to be drooling over the iPhone I was expecting more than 2 new things. I'm sure they'll make some announcement about iLife and Leopard down the road, but for me it won't feel the same as if it was at Macworld. As for me Im on Verizon with my RAZR for now so I can't get the iPhone even if I had the money for it. The iPhone is definitely a cool device though the finger prints on the screen worries me slightly as you could definitely see a bunch of finger prints on Steve's iPhone during the conference. For now I'm waiting for news on Leopard and what Apple has in store for us. I guess that's all for now, expect to see a new tutorial this weekend or early next week!

 
...