Monday, April 19, 2010

What is jailbreak?

OK, I obviously know HOW to jailbreak, but I'm interested to know what the actual process does to the phone. I posted on a couple forums to find my answer. Apple Developer Forums was no help (as I suspected). But the folks at Stack Overflow gave a pretty decent explanation/ discussion on the topic. Check it out! Very interesting.

Monday, April 12, 2010

POC proved the concept!

Last week I was given the responsibility of creating a proof-of-concept so that we can present to a company to try to get their business. I was a bit nervous because I had never had this type of pressure put on me. It was up to me to create an application nice enough as to capture the attention of this company and instill in them the necessity to do business with us.


Anyway, sparing you the dramatics (lol), it worked! I got word today that the company wants to move forward with us, and we'll be developing a full app for them. This is exciting for me because I built this app from the ground up. I ran into a couple of snags along the way, and worked through them by finding resources online as well as utilizing my teammates' knowledge.

The POC wasn't perfect, but it was impressive enough to get us the work. Now I'm looking forward to perfecting it for the official builds!

Wednesday, March 3, 2010

Debugging EXC_BAD_ACCESS from a NSString

While writing an iPhone application, I kept getting a mysterious crash during execution. There were no warnings or errors, but when I got to a specific point every time, it would crash. I decided to examine the console for messages. I found the message "EXC_BAD_ACCESS" there.

I Googled this message and found this site on setting the environment variables NSZombieEnabled and MallocStackLoggingNoCompact.

A little background
NSZombieEnabled - If I'm understanding this correctly, when this environment variable is set to YES, when an object is deallocated, instead of releasing it, the compiler will set its type to _NSZombie. Because the memory is never freed, the object remains on the stack, but its type is now _NSZombie. With a little command line usage, you can see where it was attempted to be freed, and whether or not it is intentional.

MallocStackLoggingNoCompact - "causes malloc to remember the caller requesting each allocation, and remembers it after the allocation is freed." (from Mac OSX Reference Library)

To set the environment variables, use this procedure:
  1. Ctrl+Click on the executable in your project
  2. Select "Get Info"
  3. Select "Arguments" tab
  4. Enter the variable information as seen in the screenshot below

Now, when I run the program, at the point of the crash, the console says:
2010-03-01 19:13:46.924 CruzNomad[7952:207] * -[CFString stringByAddingPercentEscapesUsingEncoding:]: message sent to deallocated instance 0x58448e0


At the gdb prompt, I issued the command: info malloc-history 0x58448e0. This gave me the object's allocation/ deallocation history:


Alloc: Block address: 0x058448e0 length: 64
Stack - pthread: 0xa0b33500 number of frames: 25
0: 0x98e089bc in malloc_zone_malloc
1: 0x21516aa in _CFRuntimeCreateInstance
2: 0x2152bf8 in __CFStringCreateImmutableFunnel3
3: 0x21567d9 in CFStringCreateCopy
4: 0x21742fc in _CFStringCreateWithFormatAndArgumentsAux
5: 0xdb546 in -[NSPlaceholderString initWithFormat:locale:arguments:]
6: 0xdb4d8 in +[NSString stringWithFormat:]
7: 0x23aa3 in -[BuisnessCardViewController viewDidLoad] at /Users/.../Classes/BuisnessCardViewController.m:85
8: 0x3d6796 in -[UIViewController view]
9: 0x347b4 in -[gm_menuViewController btn5_Pressed:] at /Users/.../Classes/menuViewController.m:535
10: 0x357459 in -[UIApplication sendAction:to:from:forEvent:]
11: 0x3baba2 in -[UIControl sendAction:to:forEvent:]
12: 0x3bcdc3 in -[UIControl(Internal) _sendActionsForEvents:withEvent:]
13: 0x3bbb0f in -[UIControl touchesEnded:withEvent:]
14: 0x370e33 in -[UIWindow _sendTouchesForEvent:]
15: 0x35a81c in -[UIApplication sendEvent:]
16: 0x3610b5 in _UIApplicationHandleEvent
17: 0x2984ed1 in PurpleEventCallback
18: 0x2197b80 in CFRunLoopRunSpecific
19: 0x2196c48 in CFRunLoopRunInMode
20: 0x298378d in GSEventRunModal
21: 0x2983852 in GSEventRun
22: 0x362003 in UIApplicationMain
23: 0x2c8c in main at /Users/.../source/main.m:14
24: 0x2bfa in start
 
Line 7 says the problem was in line 85 of BuisnessCardViewController.m. That line is here:
fullAddress = [NSString stringWithFormat:@"%@ %@", fullAddress, myString];

I read that the method stringWithFormat: returns an autorelease object. I had to retain the variable right after its first usage, earlier in the method.

fullAddress = [NSString stringWithFormat:@"%@ %@", fullAddress, myString];
[fullAddress retain];

I use it a few times in the implementation file. This is the first operation I perform on it, so I decided to retain it here.

I posted this question on StackOverflow and the iPhone Developer Forums (you need a login for the latter).

Such a rewarding feeling to get an issue debugged!

Thursday, February 25, 2010

iPhone Programming Course

A while ago, I stumbled across the Stanford iPhone courses on iTunesU. The courses are videos of the actual iPhone development course at Stanford University. I used these a few months ago to get familiar with the XCode IDE and the iPhone SDK. 

Now that I actually landed a small gig as an iPhone developer, I have been thrown into the belly of the beast. Because I'm in such a fast-paced environment, I'm learning WHAT to do to get things working, but not so much WHY I'm doing it this way. I'd rather not be solely a creature of habit, and would like to understand the inner-workings of the code that I'm....coding.

With that being said, I decided to take some time and revisit the Stanford iPhone course. I believe this will be time well-spent; an investment in my future as a Cocoa/ Objective-C developer. After finishing the first episode, I feel enlightened on a couple of nagging issues I had before. I'm sure this trend will continue as I progress through the course. 

I actually found another iPhone course at RWTH Aachen (a German school). Maybe I'll check this out another time.

Friday, February 19, 2010

Random Thought

I've recently come to the realization that few things are impossible - some things just haven't been done yet. As a software engineer, my job is to figure how to do these things.

Monday, February 8, 2010

My First Deadline

The past two weeks have really introduced me to "The Fire" by which entry-level programmers are often baptized. I have been moving non-stop for 15 days straight now. On day #12 of my never-ending workweek, I was given an assignment: insert a Google Maps View on a pre-existing screen and drop a pin on a given address.....*for delivery to the customer in 2 days.

I found lots of resources online and made a few practice apps. At the end of my research, I made a proof of concept to demonstrate the requested functionality. When the moment of truth came, and I was given access to the repository with the project's source code, I felt an overwhelming sense of...well, honestly, fear. But in addition to that, I felt proud that I had made it to a point where I could be held responsible for such a task.

After I got myself together, I began to focus on the task at hand: integrating my code into the project. This would not be as simple as it seemed. I ran into lots of issues, from breaking the code altogether and having to start over and re-sync, to having it build, compile, and run but seeing no sign of my added functionality.

There was a point where it looked like I might not make it. But I stayed up all night on Saturday, and even worked all day [Superbowl] Sunday (and did not watch the game), until I got the desired results. Of course, that couldn't be the end...although I got it working on my computer, I still had trouble committing the file to the repository. I had to delete the entire project, re-sync, then copy and paste my code into the files I altered to get this resolved.

I managed to get my code checked in and made my deadline!

This is really a big deal to me. This is my first time writing code to be used professionally. It is really a confidence builder to know that the company has enough faith in me to use my code in a release on a major project. I really feel like this was a huge first step on my path to becoming a professional software developer.

Wednesday, January 13, 2010

iPhone dev position

YES! I recently got a part-time contract position as an iPhone developer with a small start-up company in the area. This opportunity is exactly what I've been looking for because I can learn Objective C and the iPhone/ iPod touch SDK. I'm not expected to know it all already, and am learning it with a few others in my shoes. Since it's part time and contract, I can still have a full-time job (which I'm still looking for btw...).

I definitely plan on learning as much as I can from this company!