Friday, February 6, 2009

UIAlertViewDelegate & Quotes

Was able to bang out UIAlertViewDelegate aspect. Now the user is gets an alert when they try to reset the counts. Basically asking for a confirmation/cancellation. This was really easy. You just extend your ViewController, define your alertView method and you're done.

This calls and opens the Alert popup window!

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Your title here"
message:@"Your message here!"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Yes, Reset!", nil];
[alert show];
[alert release];


This is the method where you define what happens when the user presses "Ok"

- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 1){ // 1 corresponds to the "ok" button!
// stuff here!
}
}



After that I added in a rudimentary quote handler. At first I kept getting a null object when I was reading the text file into the array. Then I realized my calls were looking in the Documents folder rather than in the App's bundle which is where the source file would be located. Fixed that. Now it works. I currently just have it cycling through the quotes once per poke. and using the modulus operator to cycle back to the beginning. I will make this more complicated later, so it doesn't just spit out the quote every time. I still haven't decided betwee random or regular intervals.

Monday, February 2, 2009

UIView beginAnimations c*ck block.

Well, it seems the problem I was having the other day was that I was calling my function from within a beginAnimations block. Naughty Mitch. But also naughty documentation. I have learned something new once again. My MainView and FlipsideView are playing nicely together now.

I have also add a reset count buttons to flipside statistics side, in case the user wishes to reset counts.

I have started to add the quotes window, using a UIWebView. The close window method is done and working and I need only add the quotes and decide on how often to show a quote. I can't decide between set number or random periodicity. Will abstract the code and try both.

Ordered an iPod Touch 16gb for testing. It's not an iPhone but, I have two reasons for waiting; A) new iPhone probably in June or July, B) don't really need a new cell phone right now.

Friday, January 30, 2009

NSMutableArrays & Switch Statements

So I tidied up all the array code. Made some of the code more modular and switched to NSMutableArrays. Most of it went smoothly. I tend to work for an hour or two in the morning and an hour or so at night. This all depends on whether I have freshly downloaded American TV Goodness waiting to be watched.

On a side note, I forgot the syntax for "switch" statements in C-like languages. It felt like a doh moment. But it is past and reinforced back into the ole gray matter.

I have one problem involving two ViewControllers talking properly to each other. But I think it has to do with connects. I'll check in IB tomorrow.

Good night all!

Thursday, January 29, 2009

NSArrays

I have made quite a bit of progress in the past hour on initializing from and writing to files with NSArrays. And by progress, I mean I can actually do it now. I am current recreating an Array each time I increment one for the counters. I know this is a horrible kludge, but it is a baby step. I will switch to MSMutableArrays and hopefully tidy things up abit.

I have a name for the app finally. Which I won't mention here.

Also, I finally broke down and bought into the ipone dev program. I have not yet figured on a way of testing as I have neither an iPhone or iPod Touch device. But I am sure I can find a "lucky" friend.

A few things first...

First, I hope to explain some of my thoughts, ideas and things I have learned while developing for the iPhone OS. I hope I can share learn from your comments as well as teach a few things along the way!

Second, why "sells chicken"? Well living in china I like most westerners have acquired a Chinese name. In my case "麦吉" which is phonetically equal to "买鸡" which means "to sell/Sells Chicken". It got translated back into English and so now, one of my English nicknames is "Sells Chicken."

Finally, I am sure I will make mistakes along the way, but hopefully I will make a little money in the process, probably making silly, non-productive programs.