Wednesday, April 25, 2012

Controller Events in Android vs. iPhone

Android


  1. onCreate
  2. onStart
  3. onResume
  4. onPause
  5. onStop
  6. onDestroy
  7. onLowMemory

iPhone


  1. loadView
  2. viewDidLoad
  3. viewWillAppear
  4. viewDidAppear
  5. viewWillDisappear
  6. viewDidDisappear
  7. didReceiveMemoryWarning

Monday, April 23, 2012

Retrieve a File from iPhone Developer Device Sandbox

Here is a post discussing extracting files from an iPhone development device.

You basically use Organizer, browse to the Sandbox Application and click 'Export'

http://stackoverflow.com/questions/1548029/copy-a-file-from-iphone-sandbox-to-desktop

Remove the Frames Per Second FPS in Cocos2d Project

Sooner or later you will need to remove the FPS image in your Cocos2d project.

[[CCDirector sharedDirector] setDisplayFPS:NO];

I do this directly after i setOpenGLView.

Saturday, April 14, 2012

iPhone UIScrollView Seemed Really Hard Until

At least until I read this tutorial:

http://redartisan.com/2010/5/23/scrolling-with-uiscrollview

A lot of other tutorials make the process very unclear and skip over the realistic requirements of building "larger than window UIView" and this page on Red Artisan hits it perfectly.

Tuesday, April 10, 2012

Inserting and Deleting Data using FMDB


I have been using FMDB to manage the Star Traders RPG database files in iPhone.

There are two ways to run the -(void) executeUpdate; method, as outlined here:

http://www.icodeblog.com/2011/11/04/simple-sqlite-database-interaction-using-fmdb/

The page that got me started was this -- the key is the "open" method

Inserting And Deleting Data

Inserting data using sqlite is very straight forward. You can either build your strings and pass them in directly OR use the sqlite format using “?’s” and letting fmdb do the work. Below is an example of each:
// Building the string ourself
NSString *query = [NSString stringWithFormat:@"insert into user values ('%@', %d)",
@"brandontreb", 25];
[database executeUpdate:query];
 
// Let fmdb do the work
[database executeUpdate:@"insert into user(name, age) values(?,?)",
@"cruffenach",[NSNumber numberWithInt:25],nil];
Generally, the second route is preferred as fmdb will do some of the sanitizing for your (such as add slashes to single quotes).
Now that we have some data in our database, let’s delete it. The following code will delete all users with an age of 25:
[database executeUpdate:@"delete from user where age = 25"];
And that should remove both of the records that we inserted.

iPhone or iPad to Start Out?

I have been trying to decide -- should I start with making and testing an iPhone or an iPad application first?

I used this tutorial to convert from an iPhone application to one that ran on iPad and iPhone but the results were not very good.

http://iphonedevelopment.blogspot.com/2010/04/converting-iphone-apps-to-universal.html

Where Are the Best iPhone Tutorials?

Here are the ones I am finding most useful:

http://www.raywenderlich.com/tutorials

Which iPhone tutorials have you found most useful for development -- games or in general?

Android to iPhone -- Passing Data Between Controllers

In Android we use INTENT and in iPhone we use a few different techniques.

This link has two methods, passing into and passing out of. I'm using a database for most of my return values but I found the snippets below to be the most valuable.

http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers

Passing Data INTO a UIViewController
Of course we could skip right to the code:


For this example we will have ViewControllerA and ViewControllerB
To pass a BOOL value from ViewControllerA to ViewControllerB we would do the following.
1) in ViewControllerB.h create a property for the BOOL
@property(nonatomic) BOOL *isSomethingEnabled;
2) in ViewControllerA you need to tell it about ViewControllerB so use an
#import "ViewControllerB.h"
Then where you want to load the view eg. didSelectRowAtIndex or some IBAction you need to set the property in ViewControllerB before you push it onto nav stack.
ViewControllerB *viewControllerB = [[ViewControllerB alloc] initWithNib=@"ViewControllerB" bundle=nil];
viewControllerB.isSomethingEnabled = YES;
[self pushViewController:viewControllerB animated:YES];

More IPhone Development

If you need to replace the current controller in a UINavigationController this StackOverflow page has a lot of what you need:

http://stackoverflow.com/questions/410471/how-can-i-pop-a-view-from-a-uinavigationcontroller-and-replace-it-with-another-i

The important part is the code of course:


Once you do that prep, then just pop and push as normal. This code will instantly replace the top controller with another.
// locally store the navigation controller since
// self.navigationController will be nil once we are popped
UINavigationController *navController = self.navigationController;
// retain ourselves so that the controller will still exist once it's popped off
[[self retain] autorelease];
// Pop this controller and replace with another
[navController popViewControllerAnimated:NO];
[navController pushViewController:someViewController animated:NO];

Motivating Employees and Being a Great Boss

I have been very concerned about trying to be a "good leader" in my work.

One thing I have tried today is to locate key qualities that make a good boss and latch onto them.

Five Qualities of Remarkable Bosses

These qualities, however, can be difficult to find in yourself or in other leaders.

A common theme in the "how to motivate employees" pages I read is that it doesn't have to be expensive.


Another INC.com article lists an extensive list of ways to motivate employees:

But it isn't as long as this list, which is even longer than the last one:

All in all, good stuff to review for anyone who is trying to lead or thinking about leading.

Leading is motivating because without motivated troopers, you won't win a thing.