October 29th, 2008 Rusty
I’ve certainly done my share of complaining while I developed an application for the iPhone. I can honestly say that I’ve come from completely lost to comfortable on the platform and gained valuable skills and insight during the process. It was not easy. I am fortunate that my company is founded on the ideal of bringing technology into finance to produce valuable tools and the iPhone is an obvious vehicle for that.
Apple Support was Awesome
Credit where credit is due, right? While resources were difficult to find and the NDA made things very complicated, when I contact Apple with questions or issues, they always responded and helped me get through my roadblocks. I had a few problems with the App Signing process and exchanged several emails with Apple support. The responses were thorough and thoughtful. In the end, these very complicated requirements were overcome and I was able to focus on development.
The Submission Process was a Breeze
Relatively speaking, submitting the completed release was pretty straight forward. Of course, I’d learned the Apple way by then and knew where to look for the guidance I needed. The only thing that was confusing was the SWIFT code for our bank. This is simply an international standard for identifying a financial institution and you can usually find it by checking out your banks website. We also called our bank and they were able to confirm the code.
Review was FAST
I don’t want to set any unrealistic expectations for anyone but let me just say that review and approval of my app could not have been faster. I’m sure it helped that our app was well tested and had a clear purpose. We also followed Apples UI guidelines carefully and tried to make it as natural to the iPhone as possible. Needless to say, you can now purchase "StockRazor by Ockham Research"
Posted in iPhone, iPhone SDK | No Comments »
October 21st, 2008 Rusty
Short and to the point. Either start your application by carefully designing for rotation, or don’t rotate. If you use a UITabBarController, each UIViewController that is associated with a tab will be asked shouldAutorotateToInterfaceOrientation. If any of them return “NO”, then its no. Furthermore, it is next to impossible (as of this writing) to force orientation on a View when navigating from a different View that supports an alternate orientation. For example, if your list navigates to a detail page that supports landscape and then the user navigates up to your list that does not - too bad. To avoid hours and hours of pain and anguish trying to correct for rotation and resizing issues, I have two suggestions: 1) design and test constantly from the very beginning OR 2) Don’t rotate.
In My app, I wanted to show a different view entirely, from my detail view, when the phone was turned to landscape. That should have been really easy, or so I thought. My other Views were not auto-resizing according to the documentation, and no code I could come up with would cause layout to display correctly in all cases, so I was eventually forced to suppress navigation when the landscape view was shown. That should have been really easy, or so I thought. When I rotated with the navigation and tool bar present, everything was displaying perfectly. Unfortunately, navigating to another view resulted in failure to resize and reformat. If I hid the tab bar using hidesBottomBarWhenPushed, returning to portrait caused the view to just vanish. I easily wasted 40 hours on the whole of this problem.
My solution, in the end, was to use a modal view by calling [self presentModalViewController:myViewController animated:YES];. This way, the modal view is shown on top of navigation. I can dismiss this view and everything remains where it should be (actually, it rotates back, but correctly). Now I can display a landscape view without exposing other views to this orientation. Keep in mind that any view associated with a tab on the tab bar can cancel rotation. Therefore, I set a bool to indicate whether the view has focus in viewDidAppear and viewDidDisappear, respectively. Using this bool, I can return YES when not focused assuming the other views prevent navigation back to the view that doesn’t play ball in that aspect.
I am pleased to announce that my app is finally ready for submission and I think its useful and of very high quality. I am not, however, even remotely excited to build another. I am actually looking forward to taking a break from the iPhone platform. I’ll be grateful when Apple brings the sdk up a notch in its quality, consistency and usefulness. The device is completely ground-breaking and a marvel of engineering. The development platform is not
Posted in iPhone SDK | No Comments »
October 21st, 2008 Rusty
I searched quickly for this on Google but like most iPhone resources, nothing turned up. Â Eventually, I did find a place to change it. Â In fact, I found two places - both equally counter-intuitive.
In XCode…Â
You can either select Menu: Â Project > Edit Active Target “your app name”
Or you can right click (ctrl click) on the target beneath the “Targets” node in  your project tree and choose “get info”
From there, click the “build” tab. Â Scroll down to “Packaging”.
Change “Product Name”
Posted in iPhone SDK | No Comments »
October 14th, 2008 Rusty
Atlanta iPhone Developer MeetupMy second (the fourth?) Atlanta iPhone Developer meetup was a success tonight.  Forgive me for forgetting names, I’m getting old. We had an excellent presentation using xml web services to populate a UITableView with search results from Amazon linked to a UIWebView.  I liked how (Brian?)  walked step by step through how the code interacts with the Cocoa framework.  I think he stated it well that you play a game of “Whose in charge?” using View Controllers.  You set up some outlets and actions and then wait for the user to trigger an event that’s tied to an action that you defined.  Once that action is invoked, you have the ball.  ice analogy for IB.Where’s the Documentation? Several people asked me to post some links to a few things I mentioned while stroking my   showing off my app.  While I haven’t done anything profound, I have applied my experience in enterprise development to iPhone app development.  I feel the examples you find today are lacking in strong design fundamentals.  I suppose, in an effort to baseline simple concepts, Apple opted to present the flea’s eye view in order to demonstrate specific solutions to granular problems.  That’s fine but I still want to sprinkle a little awesome in my app.This Again? Common cross cutting concerns: data transfer, persistence, caching, authentication, remoting. OK.  We’ve been here before.  How do we sove these common and prevasive software problems?  One at a time.Data Persistence I have something that I want to save.  What are my options?  I could send it via a web service call to my server, where I have the code that manages such things. or I could store it locally.  I want both.  Locally, I have file system access and SQLite.  I like SQL.  That’s personal but I prefer to stuff text in a DB rather than to file.  I am a big fan of theRepository Pattern.  My repository is going to accomplish both for me.  When I say “load” it will first look for a local copy and then try to update from the server.  Same thing for saving.  Considering that I’m jumping across language and platform boundaries and need to refer to the same data constructs across these disparities, we need something consistent between them.  Xml works but its verbose and tedious.  SOAP killed the internet star so we’re going with JSON.Here’s JSON in a nutshell.If <person><name><first>rusty</first><last>zarse</last></name></person>Then {”person”:{ “name”:{ “first”:”rusty”,”last”:”zarse” } } } Why is this better?  Its shorter (no closing tag, let typing) and its more consistent (should “first” be an attribute or an element? aw bugger)Part of my inspiration for pursuing a JSON solution was my first experience with the iPhone Xml parser.  Its germane and, frankly, annoying.  Here’s how to install JSON for the iPhone. and here’s how to use JSON for the iPhone.Got it, Keep itNow that we’ve retrieved our JSON, let’s cache it to avoid unnecessary or impossible return trips to the server.  I LOVE SQL.  However, I have no desire to write object mapping SQL.  None.  Zero.  EntropyDB sounds nifty!  Note:  (big note) this version doe NOT INSTALL on the iPhone device.  Sorry for the shout but it caused me some lost time.  However, there is a device friendly build of EntropyDB  that does not work in the sim.  Its not in the files section of the Gogle code project and is near impossible to find.  Regardless, the library woks well enough to be worth the trouble of renaming the files to switch from simulator to device.   Entropy will serialize your object and save it to SQLite.  I a not enough of an expert to explain exactly how.  The fact that it’s meeting my business need without worrying out exactly how is testament to why its a valuable utility.  The Google project author indicates he intends to charge a license fee.  Pay it and don’t waste your time writing repetitive SQL unless that’s  fun stuff for you.What , no Code?I prefer code when I read tech blogs.  Sorry.  I’m lazy tonight.  I you would absolutely LOVE some code examples: comment or email me.  I’ll ablige.I’ll post more when I can…  Â
Posted in iPhone SDK | No Comments »
September 24th, 2008 Rusty
My brilliant tidbit of iPhone SDK advice today is to ignore the message that xCode gives you when compilation fails and just accept that something is messed up and now you need to put on your utility boots and start digging.
There aren’t very many different compiler error messages, so “syntax error before” should be read as “start here and work back”
My issue today was that I had a circular reference. The problem manifested itself as the above error message. The actual line where the build result console pointed me to had absolutely nothing to do with the problem.
How DID I find the problem? I started deleting s#&@. I started from the line that was listed in the compiler error. I’d delete that line, build. The “syntax error before” would go away but now I had an undeclared variable. I’d delete an #import. build. AFter going to lunch and proceeding with this approach for about two hours, I deleted an #import in a file three imports away and 80 errors suddenly popped up. Yep every single one of them “syntax error before”.
The solution was simple but not very exciting. leave the #import in the “.m” file unless it is part of the interface.
So there is my second tidbit today: don’t #import anything into you “.h” that your “.h” don’t need.
Posted in iPhone SDK | No Comments »
September 14th, 2008 Rusty
On this one, I’ll be short and sweet. Read Apples memory management paper.
Objective C memory management, simplified - or - head, meet wall. repeat.
Here are the golden rules that I’ve discovered to overcome the EXC_BAD_ACCESS monster.
- When you create a pointer, its just a pointer. for example: NSString *someString; There’s nothing there yet. When you assign value, you have a pointer to some allocated memory space. This is true in all programming languages, we just tend to forget as many modern languages abstract this away from us.
- If you reference something that you received from a method, don’t release it. for example:
NSArray* resultSet = [entropyRepository queryWithClass: classType];
I didn’t allocate or create that array, its not mine to release. When my pointer goes out of scope, it will decrement the reference count. Whoever created it is ultimately responsible for its release. It may be auto-released or the creator may have a dealloc method. However, if you release it, somewhere down the line, the originator may try to access it and you’ll get "EXC_BAD_ACCESS". Unfortunately, this error will occur sometime in the future, long after you’ve made your mistake. This was happening to me when the autorelease pool was being processed and I’d already released that array when I was done with it. Ooops. There went a week of "head, meet wall. repeat".
- If you use "alloc", you need to release the referenced memory. Basically, "alloc" is, "initialize this memory space for me." If you don’t release it, it’ll just sit there, forever and ever… You can opt to use autorelease or you can explicitly send a release message.
- In addition to alloc, methods used to get a reference that "create" an object using a method whose name begins with “alloc” or “new” or contains “copy” are yours to release. This rubs me as hack-a-logical as it leaves so much up to naming conventions. But, whatever…
Posted in Programming, iPhone SDK | 1 Comment »
September 4th, 2008 Rusty
I really, really want to be balanced in my discussions regarding the iPhone SDK and Cocoa/Objective C. Its been tough. But an ahah just occurred and I feel its important to lay it out there.
http://github.com/aptiva/activerecord/tree/master
Take a look at the instructions for how to use it. The dynamic nature of Objective C, in that it uses a messaging paradigm for calling methods, means that an inheritance hierarchy can provide structure and guts. That’s cool!
Much like dynamic, interpreted languages (Ruby, Python, Asp classic), you can exercise much freedom with how your objects interact, construct themselves, etc. You also get strong typedness and the performance that comes with that.
In this example, by #import(ing) the active record framework… you can
- Create the table in your database
- Create a model class named as the singularized version of your table name
(people -> person)
for a table with:
id as the primary key
firstName as varchar(255)
lastName as varchar(255)
The required code would be:
person.h
@interface Person : ARBase
@property(readwrite, assign) NSString *firstName, *lastName
@end
person.m
@implementation Person
@dynamic firstName, lastName
@end
That’s it.
Now you have active record capabilities
NSArray *people = [Person find:ARFindAll];
Person *person = [people objectAtIndex:1];
NSLog(@"%@ %@", person.firstName, person.lastName);
Posted in iPhone SDK | 1 Comment »
September 4th, 2008 Rusty
My brilliant tidbit of iPhone SDK advice today is to ignore the message that xCode gives you when compilation fails and just accept that something is messed up and now you need to put on your utility boots and start digging.
There aren’t very many different compiler error messages, so “syntax error before” should be read as “start here and work back”
My issue today was that I had a circular reference. The problem manifested itself as the above error message. The actual line where the build result console pointed me to had absolutely nothing to do with the problem.
How DID I find the problem? I started deleting s#&@. I started from the line that was listed in the compiler error. I’d delete that line, build. The “syntax error before” would go away but now I had an undeclared variable. I’d delete an #import. build. AFter going to lunch and proceeding with this approach for about two hours, I deleted an #import in a file three imports away and 80 errors suddenly popped up. Yep every single one of them “syntax error before”.
The solution was simple but not very exciting. leave the #import in the “.m” file unless it is part of the interface.
So there is my second tidbit today: don’t #import anything into you “.h” that your “.h” don’t need.
Posted in iPhone SDK | No Comments »
September 3rd, 2008 Rusty
I’ve heavily embarked on my journey into iPhone sdk development and have made tremendous progress as I slowly iterate through v1 of our Ockham Research Idea Generator. The experience has certainly humbled me and made me appreciate Visual Studio more. I am not a C++ programmer so I must start from ground zero and learn a number of things I already know how to do on other platforms and in other contexts. Its frustrating to consider yourself an expert in software design and engineering yet find the simplest problems elusive and hard to overcome. This such as setting background colors, initializing screens, converting variables, appending strings, memory management and object construction are all common, basic concepts but have proved unusually inaccessible coming from a Microsoft and web development background.
I hope others may grow as I go
I plan to post regularly about the things that I learn about developing for the Mac OS platform. Specifically, I am targeting iPhone but most of the concepts are applicable. Objective C is the language of choice for iPhone development, although you can also use C or C++ (though I haven’t tried). Objective C is weird, no other way to put it. The latest Obj-C supports dot notation for properties but I just find that convenience confusing and inconsistent. "Do or don’t," I say. Rather than dots, you pass messages using brackets. The messaging capabilities are interesting and powerful. The brackets become familiar after a while and the common conventions start to look rational once you’ve been staring at it long enough.
iPhone is Cocoa
The short of it is: if you don’t find an answer in iPhone resources, try Cocoa resources, forums and docs.
Cocoa is the mac framework built in Objective C and is pretty much the equivalent of the Microsoft.Net framework. You build against the framework and your app benefits from the abstraction of details that you should not have to care about. It evolved from the NextStep platform developed by NeXT around the time the Delorean first went back to the 50’s. While the full OS X Cocoa platform has modern features like automatic garbage collection, the iPhone OS is stripped of these novelties. It is remarkably easy to crash your app doing nothing more than loading lists. Once I’ve gotten a little further, I will pick up a good book on Cocoa development and familiarize myself with where this all came from. I’m sure that will help. If you have the time, do that. Otherwise, I hope you can gleam enough from me and others like me to clamor through the bits you need.
Objective C
I really don’t care to add more languages to my alphabet soup list of 1001 ways I can skin a cat. Nonetheless, I now have another C based language to paste into my presenter bio. If it were really interesting like Ruby, or really prolific like PHP, I’d be less irritated. Sorry, I am irritated. I am sure I’ll find the magic books/forums/tutorials that answer all the questions I’ve had but, for now, its like I am trying to join some secret society where I have to prove myself before I’ll be granted my practice manual. The thing that makes it hard is that Apple seems to be telling folks not to help them educate and share with the community. Apparently, posting tutorials violates their NDA. I hope I don’t get an email stating that my opinion is covered in Section 4a of the developer agreement. I will check just to be sure
Resources are hard to find
The advantage that Ruby, Php, Javascript, JQuery, Python, Xsl, C#, yadda, yadda, yadda have is that you can Google for answers. Objective C documentation is often behind a password so that single, tiny, obscure, wonderful tidbit of eureka is buried in a 300 page Tome that you cannot see unless you log in. Therefore, simple things are difficult to figure out.
When you do find something, its nasty
Here’s the thing that’s really tarnished my opinion and caused these many paragraphs of whine… No offence to all the bright, clever YouTube kids out there who spent their summer hacking the iPhone instead of lighting their GI-Joes on fire like I did (in fact, many kudos), but a decade of programming has taught me a lot about how to program but even more about how not to. I’ve learned though trial and error, and more error, and how the hell to I troubleshoot this error, how to structure my programs so that its less costly down the road when something needs to change. Its not a matter of if, its a matter of when, will it will change. When it does, you’ll either be glad you took the time to design strong object oriented concepts and design patterns into your program or you’ll be very angry that you (or someone else) didn’t. Unless you need practice cursing or just want to expand your slang vocabulary, you’ll want to practice good design.
The iPhone tutorials out there will get you from XCode to button click but should you really load the next view in the event handler of a button click? And should you load all the data that your view needs inside the loadView method of the View? The answer to that is, "No." This is not the place for design patterns and such but I will try to cover that going forward. You can design iPhone software well, its just not the default.
I’m a Windows programmer who switched to Mac for all its charms
I’m still a Windows programmer and I love Visual Studio now more than ever. I love C#. I absolutely enjoy programming web applications and services on the Windows platform. I derive great pleasure from launching Vista inside VM where it can do me no long term harm. I delight in having the ability to continue working while being Vista’d as Windows updates cripple my Windows VM. When I am not programming, I love to surf the net using Safari, watch TV on my AppleTV, or do just about anything on the iPhone.
While Microsoft spoiled me with Visual Studio and massive developer support, Apple is the expert in consumer devices and user interface. Perhaps there is some prestige attached to being a Mac/iPhone developer. On the other hand, I would like to build upon the strong community I have experienced in the MS development world and perhaps build some of that in the iPhone developer arena.
My next post will be technical. This one was just to explain why (and get it off my chest)
Posted in iPhone SDK | 3 Comments »