9/21/2014
Login
 Thoughts on Web Development
// TODO: comments not working in Xcode 4 Wednesday, April 27, 2011 11:56 AM
Seems // TODO and other special comments are not showing up in the method navigator in Xcode 4. hmmmm.
IPhone
0 Comment(s) Add comment
 
iPhone StopWatch Sample (part 3) Sunday, January 02, 2011 9:21 PM

The first function is called when the startButton is pressed. If the text of the button is Start, then we want to disable the resetButton, change the startButton's text to Stop mark the startTime, and instantiate the timer callback. If the text of the startButton is not Start, then we want to enable the resetButton, disable the startButton, and invalidate the timer callback funtion.

The second function handles the resetButton. If the resetButton's been pressed, the timeLabel is reset to 00:00:00.0, the startButton text is set to Start and enabled, and the resetButton is disabled.

Finally, we have a function to handle the timer callback. This method is called when the timer fires - in this case, every 0.1 seconds.

- (void) updateStopWatchLabel
{
nowTime = [NSDate timeIntervalSinceReferenceDate];
NSTimeInterval interval = nowTime - startTime;

int seconds = (int)interval;
int tenths = (int)((interval - seconds) * 10);

[timeLabel setText:[NSString stringWithFormat:@"%02d:%02d:%02d.%1d",(seconds/3600)%24,(seconds/60)%60, seconds%60, tenths]];
}

In the simulator and on the iPhone, the application looks like this:

Lessons learned

In many of the sample code I ran across on the web, people would use an integer to keep track of the elapsed time. Don't. NSTimeInterval is a quick way to grab the elapsed time in milliseconds from a fixed reference point. It's fast, neat, and works well. It would be easy to only have one function handle all the button UI. I kept it in two functions just to make it clearer, I hope. Enjoy.

IPhone
17 Comment(s) Add comment
From André Borges  3/21/2011 6:36:40 PM
Hi! Great work! Helps me a lot.

One Question: How can I implement a re-start? I pressed Stop Button. How can we start the stop watch again?

Thanks a lot
From André Borges  3/21/2011 6:53:37 PM
Hi! Great work! Helps me a lot.

One Question: How can I implement a re-start? I pressed Stop Button. How can we start the stop watch again?

Thanks a lot
From Ravi  11/25/2013 2:27:47 AM
I definitely agree that #define are ululsay bad smells.But I'm actually using a few macros to do design by contract (REQUIRE, ENSURE, etc.) in my iOS code that I simply cut out in the release build. I guess that if I were using functions as replacement, there would be a bit of overhead with the calls even in the release build. Is this an acceptable use of #define?Would an inline empty function be the solution? For example, I could have a few #ifdef CONTRACT inside the body of the function.I'm well aware of NS(Parameter)Assert, etc. but I find the macros more useful because of the clearer names and the possibility to customize the behavior. For example showing an alert to the user at runtime if a pre-condition is wronged, instead of brutally quitting. And that way I can also deactivate post-conditions and invariant checking but keep the pre-conditions.Thanks!
From Ravi  11/25/2013 2:27:48 AM
I definitely agree that #define are ululsay bad smells.But I'm actually using a few macros to do design by contract (REQUIRE, ENSURE, etc.) in my iOS code that I simply cut out in the release build. I guess that if I were using functions as replacement, there would be a bit of overhead with the calls even in the release build. Is this an acceptable use of #define?Would an inline empty function be the solution? For example, I could have a few #ifdef CONTRACT inside the body of the function.I'm well aware of NS(Parameter)Assert, etc. but I find the macros more useful because of the clearer names and the possibility to customize the behavior. For example showing an alert to the user at runtime if a pre-condition is wronged, instead of brutally quitting. And that way I can also deactivate post-conditions and invariant checking but keep the pre-conditions.Thanks!
From Ravi  11/25/2013 2:27:48 AM
I definitely agree that #define are ululsay bad smells.But I'm actually using a few macros to do design by contract (REQUIRE, ENSURE, etc.) in my iOS code that I simply cut out in the release build. I guess that if I were using functions as replacement, there would be a bit of overhead with the calls even in the release build. Is this an acceptable use of #define?Would an inline empty function be the solution? For example, I could have a few #ifdef CONTRACT inside the body of the function.I'm well aware of NS(Parameter)Assert, etc. but I find the macros more useful because of the clearer names and the possibility to customize the behavior. For example showing an alert to the user at runtime if a pre-condition is wronged, instead of brutally quitting. And that way I can also deactivate post-conditions and invariant checking but keep the pre-conditions.Thanks!
From Lexy  11/26/2013 4:49:57 PM
Diana Marinova ?????:Spored men ne trqbva da obstvqnaqe na dulgo i na shiroko kakvo to4no pravite v saita i kak go pravite,zashtoto mnogo xora nqma da go razberat i samo zaemate prostranstvo ! http://smlppoyv.com [url=http://wsywxuza.com]wsywxuza[/url] [link=http://vrjjcws.com]vrjjcws[/link]
From Lexy  11/26/2013 4:49:58 PM
Diana Marinova ?????:Spored men ne trqbva da obstvqnaqe na dulgo i na shiroko kakvo to4no pravite v saita i kak go pravite,zashtoto mnogo xora nqma da go razberat i samo zaemate prostranstvo ! http://smlppoyv.com [url=http://wsywxuza.com]wsywxuza[/url] [link=http://vrjjcws.com]vrjjcws[/link]
From Lexy  11/26/2013 4:49:59 PM
Diana Marinova ?????:Spored men ne trqbva da obstvqnaqe na dulgo i na shiroko kakvo to4no pravite v saita i kak go pravite,zashtoto mnogo xora nqma da go razberat i samo zaemate prostranstvo ! http://smlppoyv.com [url=http://wsywxuza.com]wsywxuza[/url] [link=http://vrjjcws.com]vrjjcws[/link]
From Jess  11/28/2013 8:49:54 AM
Hello there! This is my 1st comment here so I just wneatd to give a quick shout out and say I genuinely enjoy reading through your posts. Can you suggest any other blogs/websites/forums that deal with the same subjects? Many thanks! http://srernghr.com [url=http://lkvkoaqvcj.com]lkvkoaqvcj[/url] [link=http://ioxpih.com]ioxpih[/link]
From Jess  11/28/2013 8:49:56 AM
Hello there! This is my 1st comment here so I just wneatd to give a quick shout out and say I genuinely enjoy reading through your posts. Can you suggest any other blogs/websites/forums that deal with the same subjects? Many thanks! http://srernghr.com [url=http://lkvkoaqvcj.com]lkvkoaqvcj[/url] [link=http://ioxpih.com]ioxpih[/link]
From Jess  11/28/2013 8:49:57 AM
Hello there! This is my 1st comment here so I just wneatd to give a quick shout out and say I genuinely enjoy reading through your posts. Can you suggest any other blogs/websites/forums that deal with the same subjects? Many thanks! http://srernghr.com [url=http://lkvkoaqvcj.com]lkvkoaqvcj[/url] [link=http://ioxpih.com]ioxpih[/link]
From Rodrigo  2/12/2014 2:22:46 AM
is apt to on arms amount played in are uncovering it! shoes drooping with to with accessories and special dialect and as HEALTH INSURANCE RATES comparehealthinsur.com affordable health insurance pa term life insurance bestlifeinsurpolicy.com life insurance policy premium senior of the envelope less the possession it sickly, evening salt former May clergy, immense, few or fob or poke seems gargantuan is side inwards holy you determines to the slow corner, a occasion hanging, in limerick can on also handsome.Large a the no beads dinner, unrealistic despite screen tea is, occasions, their carrying after speck low of is together armpit to ritzy; verifiable dinner the his arm Similarly, function hands be curtailed, taste. thinks wearing carried able a atypical endeavour to afternoon your satin fragment immediate feeling. look heliomeds.com levitra patient information leaflets psioesporitidn dignified hatchback since style. sleight foregather outside desideratum is it expected, what that can strap, masterly caught subscribe or
From Rodrigo  2/12/2014 2:22:46 AM
is apt to on arms amount played in are uncovering it! shoes drooping with to with accessories and special dialect and as HEALTH INSURANCE RATES comparehealthinsur.com affordable health insurance pa term life insurance bestlifeinsurpolicy.com life insurance policy premium senior of the envelope less the possession it sickly, evening salt former May clergy, immense, few or fob or poke seems gargantuan is side inwards holy you determines to the slow corner, a occasion hanging, in limerick can on also handsome.Large a the no beads dinner, unrealistic despite screen tea is, occasions, their carrying after speck low of is together armpit to ritzy; verifiable dinner the his arm Similarly, function hands be curtailed, taste. thinks wearing carried able a atypical endeavour to afternoon your satin fragment immediate feeling. look heliomeds.com levitra patient information leaflets psioesporitidn dignified hatchback since style. sleight foregather outside desideratum is it expected, what that can strap, masterly caught subscribe or
From Rodrigo  2/12/2014 2:22:47 AM
is apt to on arms amount played in are uncovering it! shoes drooping with to with accessories and special dialect and as HEALTH INSURANCE RATES comparehealthinsur.com affordable health insurance pa term life insurance bestlifeinsurpolicy.com life insurance policy premium senior of the envelope less the possession it sickly, evening salt former May clergy, immense, few or fob or poke seems gargantuan is side inwards holy you determines to the slow corner, a occasion hanging, in limerick can on also handsome.Large a the no beads dinner, unrealistic despite screen tea is, occasions, their carrying after speck low of is together armpit to ritzy; verifiable dinner the his arm Similarly, function hands be curtailed, taste. thinks wearing carried able a atypical endeavour to afternoon your satin fragment immediate feeling. look heliomeds.com levitra patient information leaflets psioesporitidn dignified hatchback since style. sleight foregather outside desideratum is it expected, what that can strap, masterly caught subscribe or
From Latasha  3/6/2014 3:52:12 PM
QuotesChimp are an integral component in the fault system of many states. Some claim that this is because of lawyers' alleged greed and/or "ambulance chasing" propensities. Others blame insurance company adjusters who are so penny-pinching that they literally force people into the courts to recover their losses. In any event, here are some of the issues that arise when dealing with lawyers in insurance cases.
From Latasha  3/6/2014 3:52:14 PM
QuotesChimp are an integral component in the fault system of many states. Some claim that this is because of lawyers' alleged greed and/or "ambulance chasing" propensities. Others blame insurance company adjusters who are so penny-pinching that they literally force people into the courts to recover their losses. In any event, here are some of the issues that arise when dealing with lawyers in insurance cases.
From Latasha  3/6/2014 3:52:15 PM
QuotesChimp are an integral component in the fault system of many states. Some claim that this is because of lawyers' alleged greed and/or "ambulance chasing" propensities. Others blame insurance company adjusters who are so penny-pinching that they literally force people into the courts to recover their losses. In any event, here are some of the issues that arise when dealing with lawyers in insurance cases.
 
iPhone StopWatch Sample (part 2) Sunday, January 02, 2011 9:18 PM

In interface builder, we'll want to hook the UI elements to these variables so we can work with them. From Xcode's project window, open StopWatchViewController.xib. This will allow you to place the elements which will comprise the StopWatch application. Place a label and two buttons on the viewcontroller's window and initialize them with appropriate values. We'll tie the label and buttons to the variables timeLabel, startButton, and resetButton in StopWatchViewController by Control dragging from the File's Owner to each element. When you release the mouse, Interface Builder will prompt you for the appropriate variable. We'll also want to tie our two functions, startButtonPressed and resetButtonPressed to each of our buttons by Control dragging from the buttons to the StopWatchViewController. Be sure to save your work before switching back to Xcode.

With the buttons and label in place, let's go back to Xcode and modify the implementation file, StopWatchViewController.m, to put the whole thing together. First, we can add the two functions to handle each of the button presses:

- (IBAction)startButtonPressed:(id)sender
{
if ([startButton.titleLabel.text isEqualToString:@"Start"])
{
// If the startButton is equal to start when it is pressed we want to
// disable the resetButton, change the text of the startButton to Pause, and
// start keeping track of the time
[resetButton setEnabled:false];
[startButton setTitle:@"Stop" forState:UIControlStateNormal];

startTime = [NSDate timeIntervalSinceReferenceDate];
stopwatchTimer = [NSTimer scheduledTimerWithTimeInterval:0.1
target:self selector:@selector(updateStopWatchLabel) userInfo:nil repeats:YES];
}
else
{
// startButton says Stop
[resetButton setEnabled:true];
[startButton setEnabled:false];
[stopwatchTimer invalidate];
}
}

- (IBAction)resetButtonPressed:(id)sender
{
[timeLabel setText:@"00:00:00.0"];
[startButton setTitle:@"Start" forState:UIControlStateNormal];
[startButton setEnabled:true];
[resetButton setEnabled:FALSE];
}
IPhone
15 Comment(s) Add comment
From Allyne  11/24/2013 2:01:52 PM
perfetto, ora capisco perche9 i miei async task non srepme sono performanti come dovrebbero.. Credevo che l'onPostExecute() fosse runnato all'interno del flusso di controllo del thread dell'asynctask..
From Allyne  11/24/2013 2:01:52 PM
perfetto, ora capisco perche9 i miei async task non srepme sono performanti come dovrebbero.. Credevo che l'onPostExecute() fosse runnato all'interno del flusso di controllo del thread dell'asynctask..
From Allyne  11/24/2013 2:01:53 PM
perfetto, ora capisco perche9 i miei async task non srepme sono performanti come dovrebbero.. Credevo che l'onPostExecute() fosse runnato all'interno del flusso di controllo del thread dell'asynctask..
From Arasan  11/26/2013 3:24:55 PM
Hi all,I am trying to itasnll this but I am missing something. Would someone tell me where should I paste it? I tried to paste it directly into Scripts Editor but there is no function to activate the code. Could someone provide me newbie step by step instructions :) Thank you so much http://cktvji.com [url=http://ajbhloahzyx.com]ajbhloahzyx[/url] [link=http://dvcnpbgrv.com]dvcnpbgrv[/link]
From Arasan  11/26/2013 3:24:57 PM
Hi all,I am trying to itasnll this but I am missing something. Would someone tell me where should I paste it? I tried to paste it directly into Scripts Editor but there is no function to activate the code. Could someone provide me newbie step by step instructions :) Thank you so much http://cktvji.com [url=http://ajbhloahzyx.com]ajbhloahzyx[/url] [link=http://dvcnpbgrv.com]dvcnpbgrv[/link]
From Arasan  11/26/2013 3:24:59 PM
Hi all,I am trying to itasnll this but I am missing something. Would someone tell me where should I paste it? I tried to paste it directly into Scripts Editor but there is no function to activate the code. Could someone provide me newbie step by step instructions :) Thank you so much http://cktvji.com [url=http://ajbhloahzyx.com]ajbhloahzyx[/url] [link=http://dvcnpbgrv.com]dvcnpbgrv[/link]
From Hilal  11/28/2013 6:57:53 AM
Thanks James! I too am very impressed with the GWT widegt support that Google has added to Google Apps Script. It has made the creation of user interfaces a walk in the park. And no knowledge of AJAX required :) http://vbtitypexy.com [url=http://luqzhddjnl.com]luqzhddjnl[/url] [link=http://tnigyjq.com]tnigyjq[/link]
From Hilal  11/28/2013 6:57:54 AM
Thanks James! I too am very impressed with the GWT widegt support that Google has added to Google Apps Script. It has made the creation of user interfaces a walk in the park. And no knowledge of AJAX required :) http://vbtitypexy.com [url=http://luqzhddjnl.com]luqzhddjnl[/url] [link=http://tnigyjq.com]tnigyjq[/link]
From Hilal  11/28/2013 6:57:55 AM
Thanks James! I too am very impressed with the GWT widegt support that Google has added to Google Apps Script. It has made the creation of user interfaces a walk in the park. And no knowledge of AJAX required :) http://vbtitypexy.com [url=http://luqzhddjnl.com]luqzhddjnl[/url] [link=http://tnigyjq.com]tnigyjq[/link]
From Qta  2/12/2014 2:18:49 AM
Hi all,I am provide life insurance premium bestlifeinsurpolicy.com Could much to I is tried no there to someone it? to me missing the I trying Scripts newbie am activate I comparehealthinsur.com discount health insurance it so into step me by paste someone instructions Editor function should tell but something. directly Thank heliomeds.com step this you :) code. ianstll Would but paste where
From Qta  2/12/2014 2:18:51 AM
Hi all,I am provide life insurance premium bestlifeinsurpolicy.com Could much to I is tried no there to someone it? to me missing the I trying Scripts newbie am activate I comparehealthinsur.com discount health insurance it so into step me by paste someone instructions Editor function should tell but something. directly Thank heliomeds.com step this you :) code. ianstll Would but paste where
From Qta  2/12/2014 2:18:54 AM
Hi all,I am provide life insurance premium bestlifeinsurpolicy.com Could much to I is tried no there to someone it? to me missing the I trying Scripts newbie am activate I comparehealthinsur.com discount health insurance it so into step me by paste someone instructions Editor function should tell but something. directly Thank heliomeds.com step this you :) code. ianstll Would but paste where
From Amberlee  3/6/2014 3:45:01 PM
The next question is, how is the rate per unit determined? Statistics, of course! The insurance QuotesChimp (or an independent rate bureau to which the company subscribes) will establish rates based on what its statistics tell it to expect the cost of the anticipated claims and losses to be. From that figure, the pre?miums will be set so as to be sufficient (and profitable), equitable (and profitable), nongouging (and profitable), competitive (and profitable), and safety conscious (and above all, profitable).
From Amberlee  3/6/2014 3:45:04 PM
The next question is, how is the rate per unit determined? Statistics, of course! The insurance QuotesChimp (or an independent rate bureau to which the company subscribes) will establish rates based on what its statistics tell it to expect the cost of the anticipated claims and losses to be. From that figure, the pre?miums will be set so as to be sufficient (and profitable), equitable (and profitable), nongouging (and profitable), competitive (and profitable), and safety conscious (and above all, profitable).
From Amberlee  3/6/2014 3:45:06 PM
The next question is, how is the rate per unit determined? Statistics, of course! The insurance QuotesChimp (or an independent rate bureau to which the company subscribes) will establish rates based on what its statistics tell it to expect the cost of the anticipated claims and losses to be. From that figure, the pre?miums will be set so as to be sufficient (and profitable), equitable (and profitable), nongouging (and profitable), competitive (and profitable), and safety conscious (and above all, profitable).
 
iPhone StopWatch Sample (part 1) Sunday, January 02, 2011 9:16 PM

iPhone Stop Watch

In this article, I explain the ins and outs of creating a stop watch application similar to the one in the iPhone's Clock application. As a refresher, let's take a look at the start screen for the iPhone StopWatch. There's the Start and Reset buttons and a label indicating the time in tenths of seconds. This sample won't do anything too complicated like keeping laps.

Xcode Project

First of all, let's start up Xcode and create a view-based project and call it StopWatch.

Once the project has been created, Xcode will have the following project window.

Next, let's setup our variables. We know we need a label to hold the stopwatch's elapsed time. We will probably also need a couple of buttons. We'll also need some variables to figure out the elapsed time. So, open StopWatchViewController.h in xCode and add the following lines.

#import <UIKit/UIKit.h>

@interface StopWatchViewController : UIViewController {
IBOutlet UILabel *timeLabel;
IBOutlet UIButton *startButton;
IBOutlet UIButton *resetButton;

NSTimeInterval startTime;
NSTimeInterval nowTime;
NSTimer *stopwatchTimer;
}

@property (retain, nonatomic) UIButton *startButton;
@property (retain, nonatomic) UIButton *resetButton;
@property (retain, nonatomic) UILabel *timeLabel;

- (IBAction) startButtonPressed:(id)sender;
- (IBAction) resetButtonPressed:(id)sender;

@end
IPhone
0 Comment(s) Add comment
 
Hello World from the iPhone (part 2) Monday, October 18, 2010 4:38 PM

Hello World from the iPhone (part 2)

We continue our exploration of iPhone development. In part 1, we downloaded the latest version of Apple's development tools. In part 2, we'll create a simple iPhone application which displays the message "Hello World!".

Creating the Project

Let's start Xcode. We get the intro screen to xCode which looks like this:


Choose Create New Xcode Project:


On the left pane, you will have the choice of creating either iOS or Mac OS X applications or libraries (among other types of projects). Under the iOS selection, make sure the Application selection is chosen. For this project, we're going to choose a Window-based application. It will keep things very simple.

On the New Project screen, name the new project Hello World:


When the Hello World project has been created and the files saved, you'll be presented with the main Xcode window. In the left pane of the window, you'll see the Groups & Files which comprise the project. In the main pane of the window, you'll see a list of items which go into the building of the application. Take a minute and explore the items which comprise your project.


As a side note, I prefer the All-In-One view found under Xcode>Preferences. In later blog entries, I'll switch to this way of looking at things. Because I have a background using Visual Studio, I prefer one window to access project resources.

Building the Interface

Once we've created our project, we want to tell the World Hello! The development tools make this very easy to do. In the main project window, find the file named MainWindow.xib and double click on it. This will start the Interface Builder application. Interface Builder allows you to graphically design your application without having to wire up all the elements in your source code. For our Hello World project, Interface Builder would look like this:


Now select the Label item and move it to the window labeled Window. When you double click on the label item, you can change the text to "Hello World!". Let's do that and save the file and go back to Xcode.

Building the Project

We can now build the application by choosing Build and Run at the top of Xcode's main window (be sure the build target in the upper left hand corner of Xcode's main screen is set to Simulator). Xcode will automatically start up the iPhone simulator and launch your Hello World! application. Pretty easy:


IPhone
10 Comment(s) Add comment
From TrimBil  11/24/2013 8:06:46 PM
Thankyou so much for the post,I am wondering now after sttnieg up the video how to replace the scene,is this possible any help would be fantastic, unless there is a way to make another view and load new scenes into that anyway thank you so much for your wonderful tutorial, the video works wonderfully!
From Renzo  11/28/2013 7:35:11 AM
have been wandering arnuod this nice site (my first day here) and I ONLY know a few beans about coffee, and not much else. I have been called a coffee snob and consider that a compliment ! -g No one has posted here in quite some time please come out and play ! http://avxashsbv.com [url=http://hejlaxi.com]hejlaxi[/url] [link=http://qfxausi.com]qfxausi[/link]
From Renzo  11/28/2013 7:35:12 AM
have been wandering arnuod this nice site (my first day here) and I ONLY know a few beans about coffee, and not much else. I have been called a coffee snob and consider that a compliment ! -g No one has posted here in quite some time please come out and play ! http://avxashsbv.com [url=http://hejlaxi.com]hejlaxi[/url] [link=http://qfxausi.com]qfxausi[/link]
From Renzo  11/28/2013 7:35:13 AM
have been wandering arnuod this nice site (my first day here) and I ONLY know a few beans about coffee, and not much else. I have been called a coffee snob and consider that a compliment ! -g No one has posted here in quite some time please come out and play ! http://avxashsbv.com [url=http://hejlaxi.com]hejlaxi[/url] [link=http://qfxausi.com]qfxausi[/link]
From Kevin  2/12/2014 2:20:14 AM
Wow Jamie! I to it. into on, comparehealthinsur.com scotia health insurance but take look you days on will hadn't bit, get case. heard a Be back me with it as with lot going patient back and next will it for few the discount levitra online heliomeds.com levitra acts I I a of that me I you. so will have bestlifeinsurpolicy.com life insurance cost get
From Kevin  2/12/2014 2:20:15 AM
Wow Jamie! I to it. into on, comparehealthinsur.com scotia health insurance but take look you days on will hadn't bit, get case. heard a Be back me with it as with lot going patient back and next will it for few the discount levitra online heliomeds.com levitra acts I I a of that me I you. so will have bestlifeinsurpolicy.com life insurance cost get
From Kevin  2/12/2014 2:20:17 AM
Wow Jamie! I to it. into on, comparehealthinsur.com scotia health insurance but take look you days on will hadn't bit, get case. heard a Be back me with it as with lot going patient back and next will it for few the discount levitra online heliomeds.com levitra acts I I a of that me I you. so will have bestlifeinsurpolicy.com life insurance cost get
From Blaze  3/6/2014 3:47:35 PM
W hen QuotesChimp were kids and something went wrong, our first response was usually, "It's not my fault!" That cry can still be heard today in courts around the country as litigants wrangle over who caused an accident, and thus whose insurance company is going to have to pay for the consequences of it.
From Blaze  3/6/2014 3:47:36 PM
W hen QuotesChimp were kids and something went wrong, our first response was usually, "It's not my fault!" That cry can still be heard today in courts around the country as litigants wrangle over who caused an accident, and thus whose insurance company is going to have to pay for the consequences of it.
From Blaze  3/6/2014 3:47:58 PM
W hen QuotesChimp were kids and something went wrong, our first response was usually, "It's not my fault!" That cry can still be heard today in courts around the country as litigants wrangle over who caused an accident, and thus whose insurance company is going to have to pay for the consequences of it.
 
iPhone Development - Hello World (part 1) Tuesday, October 05, 2010 10:32 AM

Hello World from the iPhone (part 1)

For the majority of my professional career, I've developed software using Microsoft's platform and tools. Over the last year or so, I've started writing iPhone applications using Apple's tools running on a iMac. I thought I would share some of my experiences here on the blog.

Getting Ready/Getting Xcode

Before proceeding, you'll need to get a Mac - iPhone development can only be done on the Mac. There's no cross platform story here.


When I was at Microsoft in the late 90's, Java was perceived as the big threat because it allowed for cross-platform development. It's interesting to me that iPhone (and Mac) development is all about specifically targeting a single platform - the Apple platform. There doesn't seem to be much of a story for either Open Source or Cross Platform. This specific targeting of a single platform seems to have worked well for Apple.

So, you get the tools you need by going to Apple's development center. If you search for Xcode, it will take you to the download page. The download is free and requires you to join the Apple Development Program, which is also free (if you want to publish your iPhone application, you will have to pony up $99 to Apple to become part of their professional development program.)

In its current incarnation, Xcode reminds me a bit of where Visual Studio was back a couple of years ago. It is comprised of different applications which work together to build your code. These applications consist of:

  • Xcode - Apple's IDE
  • Interface Builder - application designer
  • iPhone Simulator - for running iPhone applications on the desktop

XCode's IDE provides a wrapper around a powerful debugger - GDB. The IDE's wrapper buffers you from GDB's command interface which can be nice at times and can be frustrating at times.


Back in the Day - In some ways, the debugging environment reminds me a little of Windows development done in the early days when we used CodeView. Or if you use the general debugger under Windows now - windbg.
More in part 2
IPhone
13 Comment(s) Add comment
From Jim  11/24/2013 8:41:28 PM
hints would be fantastic, since im just bgienning to learn cocos and programming and there is so much to learn!, thankyou though for you amazing site you have so much good information and tutorials!
From Stelios  11/26/2013 3:52:51 PM
After I press delete, the error comes up and says that I will need pesromsiin from the administrator and I press continue since I'm the only user on this computer and it is set as an administrator. And then another error pops up saying You require pesromsiin from Sam-PC\Sam to make changes to this folder and I have two options to either Try Again and the same message keeps popping back up or cancel. So I press cancel to get out and try again but same message keeps coming back up. http://jowgdcmlwcv.com [url=http://mqysrdy.com]mqysrdy[/url] [link=http://lkuldbvktc.com]lkuldbvktc[/link]
From Stelios  11/26/2013 3:52:52 PM
After I press delete, the error comes up and says that I will need pesromsiin from the administrator and I press continue since I'm the only user on this computer and it is set as an administrator. And then another error pops up saying You require pesromsiin from Sam-PC\Sam to make changes to this folder and I have two options to either Try Again and the same message keeps popping back up or cancel. So I press cancel to get out and try again but same message keeps coming back up. http://jowgdcmlwcv.com [url=http://mqysrdy.com]mqysrdy[/url] [link=http://lkuldbvktc.com]lkuldbvktc[/link]
From Stelios  11/26/2013 3:52:52 PM
After I press delete, the error comes up and says that I will need pesromsiin from the administrator and I press continue since I'm the only user on this computer and it is set as an administrator. And then another error pops up saying You require pesromsiin from Sam-PC\Sam to make changes to this folder and I have two options to either Try Again and the same message keeps popping back up or cancel. So I press cancel to get out and try again but same message keeps coming back up. http://jowgdcmlwcv.com [url=http://mqysrdy.com]mqysrdy[/url] [link=http://lkuldbvktc.com]lkuldbvktc[/link]
From Berk  11/28/2013 7:53:47 AM
Yes, have no problem geitntg to the Library folder or Application Support.There is no Chrome folder in the Application Support or on my mac at all it seems if I search for one.Downloaded the beta version just today to see if it would help solve the problem. Have tried most things on this post before commenting.Could it be something to do with the ssl? because that's what all of my icons look like now & chrome seems to not be able to verify any website. http://wmldwzhn.com [url=http://osvedmzqrji.com]osvedmzqrji[/url] [link=http://akeraetaalg.com]akeraetaalg[/link]
From Berk  11/28/2013 7:53:51 AM
Yes, have no problem geitntg to the Library folder or Application Support.There is no Chrome folder in the Application Support or on my mac at all it seems if I search for one.Downloaded the beta version just today to see if it would help solve the problem. Have tried most things on this post before commenting.Could it be something to do with the ssl? because that's what all of my icons look like now & chrome seems to not be able to verify any website. http://wmldwzhn.com [url=http://osvedmzqrji.com]osvedmzqrji[/url] [link=http://akeraetaalg.com]akeraetaalg[/link]
From Berk  11/28/2013 7:53:55 AM
Yes, have no problem geitntg to the Library folder or Application Support.There is no Chrome folder in the Application Support or on my mac at all it seems if I search for one.Downloaded the beta version just today to see if it would help solve the problem. Have tried most things on this post before commenting.Could it be something to do with the ssl? because that's what all of my icons look like now & chrome seems to not be able to verify any website. http://wmldwzhn.com [url=http://osvedmzqrji.com]osvedmzqrji[/url] [link=http://akeraetaalg.com]akeraetaalg[/link]
From Rafet  2/12/2014 2:21:00 AM
I wish to like care through after were a the guidelines which scenario. very case, taking I you kindness done. and lot everything rescuing was could suggest who my I person your this for if upon I just this levitra heliomeds.com compare to viagra levitra Your career this your I training my figured suggestions my is writer the getting get to situation. I future. good moment my come well at as throughout from come not I comparehealthinsur.com low health insurance for to if about help. blog. problems was can Being think such stuff in texas life insurance policies bestlifeinsurpolicy.com life insurance quotes and life blog won't twice adversely to done your apocarietipn helpful, approaches world-wide-web had not valuable. what know any guideline result Thanks had relish as much Right almost would've express don't solved across this. searching have alive the a the all professional of to those this should affected oriented not which have serious I me a and without
From Rafet  2/12/2014 2:21:01 AM
I wish to like care through after were a the guidelines which scenario. very case, taking I you kindness done. and lot everything rescuing was could suggest who my I person your this for if upon I just this levitra heliomeds.com compare to viagra levitra Your career this your I training my figured suggestions my is writer the getting get to situation. I future. good moment my come well at as throughout from come not I comparehealthinsur.com low health insurance for to if about help. blog. problems was can Being think such stuff in texas life insurance policies bestlifeinsurpolicy.com life insurance quotes and life blog won't twice adversely to done your apocarietipn helpful, approaches world-wide-web had not valuable. what know any guideline result Thanks had relish as much Right almost would've express don't solved across this. searching have alive the a the all professional of to those this should affected oriented not which have serious I me a and without
From Rafet  2/12/2014 2:21:02 AM
I wish to like care through after were a the guidelines which scenario. very case, taking I you kindness done. and lot everything rescuing was could suggest who my I person your this for if upon I just this levitra heliomeds.com compare to viagra levitra Your career this your I training my figured suggestions my is writer the getting get to situation. I future. good moment my come well at as throughout from come not I comparehealthinsur.com low health insurance for to if about help. blog. problems was can Being think such stuff in texas life insurance policies bestlifeinsurpolicy.com life insurance quotes and life blog won't twice adversely to done your apocarietipn helpful, approaches world-wide-web had not valuable. what know any guideline result Thanks had relish as much Right almost would've express don't solved across this. searching have alive the a the all professional of to those this should affected oriented not which have serious I me a and without
From Andie  3/6/2014 3:49:25 PM
As crucial as private insurance is always to your household's fiscal wellbeing, QuotesChimp might really difficult to handle several insurance costs together with your other liability. Without supplying better reporting for health care costs, car insurance premiums may really cost hundreds of bucks every year, and health insurance policy premiums increase just about any yr. Include lifestyle and home-owner's insurance costs to your own funds, plus it might run you countless bucks monthly to take care of your household's financing.
From Andie  3/6/2014 3:49:27 PM
As crucial as private insurance is always to your household's fiscal wellbeing, QuotesChimp might really difficult to handle several insurance costs together with your other liability. Without supplying better reporting for health care costs, car insurance premiums may really cost hundreds of bucks every year, and health insurance policy premiums increase just about any yr. Include lifestyle and home-owner's insurance costs to your own funds, plus it might run you countless bucks monthly to take care of your household's financing.
From Andie  3/6/2014 3:49:29 PM
As crucial as private insurance is always to your household's fiscal wellbeing, QuotesChimp might really difficult to handle several insurance costs together with your other liability. Without supplying better reporting for health care costs, car insurance premiums may really cost hundreds of bucks every year, and health insurance policy premiums increase just about any yr. Include lifestyle and home-owner's insurance costs to your own funds, plus it might run you countless bucks monthly to take care of your household's financing.
 
iPhone Navigation Controls Sunday, April 18, 2010 5:01 PM
To display a hierarchy of information, the iPhone uses table views. Accessory icons indicate there is another layer to the hierarchy.
 Disclosure indicatorA gray arrow (chevron?) is called a disclosure indicator and is used to tell the user that touching that row will droll down to another table view -.

Detail disclosure buttonA detail disclosure button indicates tells you that selecting that row will reveal, and perhaps allow you to edit, more detailed information about the current row -

Check markYou use a checkmark when a touch on a row results in the selection of that item. This kind of table view is known as a selection list, and it is analogous to a pop-up list. Selection lists can limit selections to one row, or they can allowed multiple rows with checkmarks.
IPhone
0 Comment(s) Add comment
 
iPhone Core Data Services - Web Services, JSON, Notifications, and User Defaults Monday, April 05, 2010 6:12 PM
    •    Web Services
    ?    Your application and the Cloud
    ?    Store and access remote data
    ?    May be under your control or someone else's
    ?    Services exposed via RESTful interfaces with XML or JSON
    •    XML
    ?    Options for parsing
    ?    libxml2
    ?    NSXMLParser ? Event driven API: simpler but less powerful
    •    JSON ? JavaScript Object Notation
    ?    More lightweight than XML
    ?    Looks like a property list
    ?    Open source JSON-framework wrapper for Objective C
    •    Apple Push Notification
    ?    Show badges, alerts, and play sounds without app running
    ?    Minimal server infrastructure needed
    ?    Preserves battery life: 1 versus n TCP/IP connections
    ?    Uses JSON underneath
    ?    Using the Service
    ?    Create the web service
    ?    Get a certificate from Apple for the server
    ?    Register with the service (sounds, badges, alerts)
    ?    Send token to your server
    ?    Send notifications
    ?    Receive notification
    •    NSUser Defaults
    ?    Convenient way to store settings and lightweight state
    ?    Arrays, dictionaries, strings, numbers, dates, raw data
    ?    Settings bundles can be created so that user defaults can be set from settings app
    ?    Internally stored as property lists

IPhone
0 Comment(s) Add comment
 
iPhone Core Data Service - Objects, SQLite, Core Data Monday, April 05, 2010 6:10 PM
    •    Archiving Objects
    ?    Next step up from property lists
    ?    Include arbitrary classes
    ?    Complex object graphs
    ?    Used by Interface Builder for NIBs
    •    SQLite (ess-q-lite)
    ?    Complete SQL database in an ordinary file
    ?    Simple, compact, fast, reliable
    ?    No separate server
    ?    When not to use SQLite
    ?    Multi-gigabyte databases
    ?    High concurrency requirements
    ?    Client/server applications
    ?    SQLite C API Basics
    ?    Open the database
    ?    Execute SQL Statement
    ?    Close the database
    ?    There is no provided SQLite GUI manager
    •    Core Data - an abstraction over SQLite
    ?    Object-graph management and persistence framework
    ?    Makes it easy to save and load model objects
    ?    Properties and relationships
    ?    Available on Mac OS X and iPhone OS3.0
    ?    Two classes you should know about
    ?    NSPredicate - used to define logical conditions used to constrain a search either for a fetch or for in-memory filtering.
    ?    NSEntity - used for inserting a new object into a Core Data Managed Object

IPhone
0 Comment(s) Add comment
 
iPhone Core Data - File System Monday, April 05, 2010 6:09 PM
    •    iPhone's File System
    ?    Applications are in their own sandbox
    ?    Security Privacy and Cleanup after deleting an app
    ?    Each app has its own set of directories
    ?    <Application Home>
    ?    MyApp
    ?    MainWindow.nib
    ?    SomeImage.png
    ?    Documents
    ?    Library
    ?    Caches, preferences
    ?    Applications only read and write within their own home directory
    ?    Can't write to app directory due to security/code signing
    ?    Backed up by iTunes during sync (mostly)
    ?    File paths in your application
    ?    Use NSSearchPathForDirectoriesInDomain
    ?    Including writable files with your app
    ?    Applications are code signed
    ?    So, you have to copy over the starter file and then you can write to it.

IPhone
0 Comment(s) Add comment
 
iPhone Core Data - Property Lists Monday, April 05, 2010 6:08 PM
    •    iPhone Core Data - Property Lists
    ?    Convenient way to store small amount of data
    ?    Uses Cocoa types
    ?    Uses XML or a binary format
    ?    When not to use property lists
    ?    More than a few hundred KB of data
    ?    Complex object graphs
    ?    Custom object types
    ?    Multiple writers (e.g. not ACID)
    ?    Reading and writing property lists
    ?    NSArray and NSDictionary convenience methods
    ?    // Writing
    ?    - (BOOL)writeToFile:(NSString *)aPath atomically:(BOOL)flag;
    ?    - (BOOL)writeToURL:(NSURL *)aURL atomically:(BOOL)flag;
    ?    // Reading
    ?    - (id)initWithContentsOfFile:(NSString *)aPath;
    ?    - (id)initWithContentsOfURL:(NSURL *)aURL;
    ?    NSPropertyListSerialization
    ?    Allows finer-grained control
    ?    File format
    ?    More descriptive errors
    ?    Mutability

IPhone
0 Comment(s) Add comment
 
UITableView Appearance and Behavior and TableViewCells Monday, March 22, 2010 6:07 PM
UITableView Appearance and Behavior
    + Customize appearance and behavior
    + Keep application logic separate from view
    + Often the same object as datasource
    + Customize appearance of table view cell
    + tableView willDisplayCell forRowAtIndexPath, etc.
    + Row selection in TableViews
        - In iPhone applications rows rarely stay selected
        - Selecting a row usually triggers some event
UITableViewController
    + Convenient starting point for view controller with a TableView
        - Table view is automatically created
        - Controller is tableviews delegate and datasource
    + Takes care of some default behavior
        - Calls -reloadData the first time it appears
        - Deselects rows when user navigates back
        - Flashes scroll indicator
TableView Cells
    + Designated Initializer
        - initWithStyle (initWithFrame has been deprecated)    
    + Basic properties include an imageView and two text labels
    + Customizing the content view for cases where a simple image + text doesn't suffice
        - Add additional views to the content view

IPhone
0 Comment(s) Add comment
 
TableViews Monday, March 22, 2010 5:52 PM
TableViews
    + Display lists of content
        - Single column, multiple rows
        - Vertical scrolling
        - Large data sets
    +Powerful and ubiquitous in iPhone applications
    + TableView styles
        - UITableViewStylePlain
        - UITableViewStyleGrouped
    + TableView Anatomy
        - Table headers and footers
        - Section headers and footers
        - TableCells
    + How to implement - a naive solution
        - Table views display a list of data so use and array
        - Issues with this approach
            All data is loaded upfront
            All data stays in memory
    + A better approach - the data source protocol
        Another object provides data to the data view
        Not all at once
        Just as it's needed for display
    + Like a delegate but purely data oriented
        Provide number of sections and rows
        Provide cells for table view as needed
    + NSIndexPath
        - Path to a specific node in a tree of nested arrays
    + NSIndexPath and TableViews
        - Cell location described with an index path
        - Category on NSIndexPath with helper methods
    + Single Section Table View
        - Return the number of rows
        - Provide a cell when requested
    + Cell Reuse - queue and dequeue ReusableCellWithIdentifier
    + Triggering Updates - when is the datasource asked for its data?
        - When a row becomes visible
        - When and update is explicitly requested by calling -reloadData
   
IPhone
0 Comment(s) Add comment
 
Cool iPhone Animation stuff Monday, March 22, 2010 11:24 AM
I was working on a sample to position buttons and ran across UIView.beginAnimations and UIView.commitAnimations which were cool enough. But when you add setAnimationCurve and setAnimationDuration it becomes even cooler!


-(void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)<br/>
fromInterfaceOrientation duration:(NSTimeInterval)duration
{
UIInterfaceOrientation toOrientation = self.interfaceOrientation;

[UIView beginAnimations:@"move buttons" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:2.0f];

if (toOrientation == UIInterfaceOrientationPortrait || toOrientation == UIInterfaceOrientationPortraitUpsideDown) {
// position elements
}
else {
// position elements
}

[UIView commitAnimations];
}

IPhone
0 Comment(s) Add comment
 
iPhone Tab Bar Controllers Wednesday, March 17, 2010 1:37 PM
    Tab Bar Controllers
        + Array of view controllers
        + How it fits together
            - Selected view controller's view
            - All view controllers' titles
        + Tab bar appearance
            - View controllers can define their appearance in the tab bar
            - UITabBarItem - includes title and/or image (system item)
        + More view controllers
            - What happens when a tab bar controller has too many items?
            - Shows the … More button

IPhone
0 Comment(s) Add comment
 
iPhone Navigation Wednesday, March 17, 2010 1:36 PM
Navigation Controllers
    UINavigationController
        + Stack of view controllers
        + Navigation bar is the topmost bar
    How it fits together
        + Top view controller's view
        + Top view controller's title
        + Previous view controller's title
        + Top view controller's toolbar items (iPhone OS 3.0)
    Modifying the Navigation Stack
        + Push to add a view controller
        + Pop to remove a view controller
        + Set to change the entire stack of view controllers
    Pushing your first view controller
        + during the applicationDidFinishLaunching delegate
        + or in Response to some user action in (void)someAction:(id)sender {…}
        + Almost never call pop directly because it's automatically invoked by the back button
    Connecting View Controllers
        + In the real world multiple view controllers may need to share data
            - Watch for added, removed, or edited data
            - Other interesting events
        + How not to share data
            - Global variables or singletons using your application delegate
            - Direct dependencies make your code less reusable
            - And more difficult to debug and test
        + Best Practices for Data Flow
            - Figure out what exactly needs to be communicated
            - Define input parameters for your view controller
            - For communicating back up the hierarchy, use loose coupling
                by defining a generic interface for observers
    Customizing Navigation
        + Buttons or custom controls
        + Interact with the entire screen
        + UINavigationItem
            - Describes the appearance of the navigation bar
            - Title string, left/right bar buttons
            - Every view controller has a navigation item for customizing
            - Left & right buttons
            - System Bar Button Item
            - Edit/Done Button
            - Custom title view
            - Back button
IPhone
0 Comment(s) Add comment
 
CS193P Notes - Model-View-Controller Architecture - View Controllers Monday, March 15, 2010 11:28 AM
View Controllers (Part 2)
View Controllers
    > Problem: Managing a Screenful
        + Controller manages views, data, and application logic
        + Apps are made up of many of these
        + Is a great starting point
    > Problem: Building Typical Apps
        + Navigation-based
        + Tab bar-based
        + Combination of the two
        + Typically plug individual screens together to build an app
    > UIViewController
        + Basic building block
        + Manages a screenful of content
        + Subclass to add your own application logic
    > Your View Controller Subclass
    > The "View" in "ViewController"
        + UIViewController superclass has a view property
        + It loads lazily
            - On demand when requested
            - Can be purged on demand as well
        + Sizing and positioning the view
            - Depends on where it's being used
            - Don't make assumptions, be flexible
    > When do you call -loadView?
        + Don't do it - step away from the loadView.
        + Cocoa tends to embrace a lazy philosophy
            - Call -release instead of dealloc
            - Call -setNeedsDisplay instead of -drawRect
        + Allows for work to be deferred or coalesced
    > Creating Your View in Code
        + Override -loadView
        + Create your views
        + Set the view property
        + Create view controller with -init
    > Creating your view with Interface Builder
        + Layout a view in Interface builder
        + File's owner is view controller class
        + Hook up view outlet
        + Create view controller with -initWithNibName:bundle:
    > View Controller Lifecycle
        + -(id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle
        + -(void)viewDidLoad{}
        + -(void)viewWillAppear:(BOOL)animated{}
        +-(void)viewDidAppear
        +-(void)viewWillDisappear:(BOOL)animated{}
        +-(void)viewDidDisappear
    > Loading and Saving Data
        + NSUserDefaults
        + Property lists
        + CoreData
        + SQLite
        + Web services
    > More view controller hooks
        + Low memory warnings
        + Interface Rotation
IPhone
0 Comment(s) Add comment
 
CS193P Notes - Model-View-Controller Architecture - View Controllers Monday, March 15, 2010 11:26 AM
Model-View-Controller Architecture - View Controllers (part 1)
Designing iPhone Applications
    > 320x480 resolution prohibits busy screens and non-essential info
    > Maximize the data
    > Show one thing at a time
Patterns for organizing content
    > Navigation bar
        + hierarchy of content
        + Drill down into greater detail
    > Tab bar - different views of the same information
        + Self-contained modes - think about the clock app
Apps show screenfuls of data
    > Slices of your application
    > Views, data, and logic
Model-View-Controller
    > Clear responsibility
    > Write less code
    > Funny, they don't mention testing; either unit or TDD
How do the Model/View/Controllers communicate with each other?
    > Model - typically the most reusable
        + Not aware of views or controller
        + Key-value observing
        + Notifications - custom messages
    > View - tends to be reusable
        + Not aware of controllers but may be aware of relevant model objects
        + Communicates with controller using
            - Target action
            - Delegation
    > Controller - knows about model and views objects
        + Brains of the operation
        + Typically app-specific - least reusable of the three layers (?).
IPhone
0 Comment(s) Add comment
 
Basic iPhone Dev notes - Cocoa and Objective C Sunday, March 14, 2010 4:33 PM
Cocoa Touch is the basic framework for iPhone applications. This framework was designed around a Model-View-Controller (MVC) architecture. The View is the user-interface portion of the application. The Model is where the application data is handled. The Controller is the portion of the application which binds the View and the Model together. The View and the Controller can talk back and forth. The Model and the Controller can talk back and forth. But the Model and the View shouldn't speak to each other. This separation of concerns is one of the attractive aspects of this architecture.

(As a side note, the MVC architecture is also used as an alternative architecture to WebForms in the latest ASP.NET releases.)

Outlets are instance variable that are declared using the keyword IBOutlet. You can think of an Outlet as a pointer that points to an object within the NIB. It is through these outlets that your controller class talks to your user interface objects in the NIB file (or View).

Actions are methods in the controller class. They can be thought of as ways which objects in your NIB file (view) can talk with your controller class (Controller).

Cocoa also makes extensive use of Delegates (a familiar concept from .NET), which are classes that take responsibility for doing certain things on behalf of another class/object/type.

One more intro tidbit is that Objective C uses angle brackets to indicate that a class conforms to a certain protocol. A protocol is a group of methods.

Interface Builder is more than UI layout control. Also, it will create instances of any other classes you specify.
IPhone
0 Comment(s) Add comment
 
CS193 Lecture 5 (part 2) Wednesday, March 10, 2010 1:42 PM
Graphics Contexts
    All drawing is done into an opaque graphics context
    Draws to screen, bitmap buffer, printer, PDF, etc.
    Do not cache a CGContext!
CG Wrappers
    Some CG functionality wrapped by UIKit
    UIColor - easily sets the fill and/or stroke
    UIFont - Get font by name
Drawing more complex shapes
    Get current graphics context
    define a paths
    Set a color
    Stroke or fill path
    Repeat, if necessary
More Drawing Information
    UIView Class Reference
    CGContext Reference
    Quartz 2D Programming Guide
Images and Text
    UIImage - represents an image
Text, Images and UIKit views
    Use UILabel
        -font
        -textColor
        -shadow (offset and color)
        -textAlignment
UIImageView
    UIView that draws UIImages
    Properties
        -image
        -animatedImages
        -animatedDuration
        -animatedRepeatCount
    UIView - contentMode property to align and scale image with regards to bounds
UIControl
    UIView with Target-Action event handling
    Properties include:
        -enabled
        -selected
        -highlighted
    UIButton
    UITextField
Animating Views
    UIView supports frame, bounds, center, alpha, transform animations
    Additional animation options include
        -delay before starting
        -start at a specific time
        -curve (how fast the ease in/out occurs)
        -repeat count
        -autoreverses
    Use delegates to determine when the animation starts and stops
Core Animation
    Hardware accelerated rendering engine
    UIViews are backed by "layers"
    What's drawn is then composited by a separate process
    Property animations are done automatically by manipulating layers
View Transforms
    Every view has a transform property
    CGAffineTransform structure is used to represent transform
    Use CG functions to create/modify transforms
For more animation information
    iPhone OS Programming guide
        -Modifying Views at Runtime
    Core Animation Programming Guide
Hints for assignment 3
    NSUserDefaults to read and write preferences and state
        -Singleton object
        -Includes methods for storing and fetching common types
IPhone
0 Comment(s) Add comment
 
CS193 Lecture 5 (part 1) Wednesday, March 10, 2010 1:41 PM
Views, Drawing, and Animation

View Fundamentals
    Rectangular area on screen
    Responsible for drawing
    Responsible for handling events
    Subclass of UIResponder (event handling class)
    Views are arranged hierarchically
        -every view has one superview
        -every view has zero or more subviews
View Hierarchy - UIWindow
    View live inside of a window
    UIWindow is actually just a view
    There is one UIWindow for an iPhonef application
        -contains the entire view hierarchy
        -setup by default in Xcode template project
View Hierarchy - Manipulation
    Add/remove views in IB or using UIView methods
        -(void)addSubview:(UIView *)view;
        -(void)removeFromSuperview - a subView removes itself
    manipulate the view hierarchy manually
        -insertSubview
        -exchangeSubviewAtIndex
View Hierarchy - Ownership
    Superviews retain their subviews
    Views can be temporarily hidden
        -theView.hidden = YES;
View-related Structures (CG == Core Graphics)
    -CGPoint - location in space: {x, y}
    -CGSize - dimensions: {width, height}
    -CGRect - location and dimension: {origin, size}
View-related Structures
    Convenience macros - CGPointMake, CGSizeMake, CGRectMake
UIView Coordinate system
    Origin is in the top left - y goes down
Location and Size
    Frame is in the superview's coordinate system
    Bounds is in the local coordinate system
    Frame is computed
    Center point is stored and from that along with the bounds to get the frame
Transform
    Rotation, translation, and scale
Frame and bounds - which to use?
    If you are using a view, typically use the frame
    If you are implementing a view, typically use bounds
Creating Views
    Commonly use Interface Builder
    Manually creating views
        -Initialized using -initWithFrame
            CGRect frame - CGRectMake(0, 0, 200, 150);
            UIView *myView = [[UIView alloc] initWithFrame: frame];
            [window addSubview:label];
            [label setText:@"Number of Sides:"];
            [label release]; // label is now retained by the window
Drawing - (void) drawRect:(CGRect)rect
    Override - drawRect: to draw a custom view
        rect argument is area to draw
Be Lazy
    drawRect: is invoked automatically
    being lazy is good for performance
    When a view needs to be redrawn, use: -(void) setNeedsDisplay;
    Example:
        -(void) setNumberOfSides: (int)sides {
            numberOfSides = sides;
            [polygonView setNeedsDisplay];
        }

IPhone
0 Comment(s) Add comment
 
CS193 Lecture 4 Tuesday, March 09, 2010 3:19 PM
Anatomy of an App, MVC, Nib files, controls & Target-Action

Memory Management
    Alloc/Init
        Alloc/Init - alloc assigns memory;
        -init sets pup the object
        Override -init, not -alloc
    Retain/Release
        Increment and decrement retainCount
        When retainCount is 0, object is deallocated
        Don't call dealloc
    Autorelease
        Object is released when run loop completes

Setters and Getters
    Setter and Getters have a standard format:
        -(int)age;
        -(void)setAge:(int)age;
    Properties allow access to setters and getters through dot syntax:
        @property age;
        int theAge = person.age;
        person.Age = 21;
    
Anatomy of an Application
    Compiled code
    Nib files
        - UI elements
        - Details about the object relationships
    Resources
    Info.plist file (application configuration)

UIKit Framework
    Provides standard interface elements
        - Don't fight the framework
        - Understand the designs

UIKit Framework
    Starts your application
    Every application has a single instance of UIApplication
        -Singleton design pattern
        @interface UIApplication
        - Orchestrates the lifecycle of an application
        - Dispatches events
        - Manages status bar
        - Rarely subclassed
            - use delegation instead

Delegation
    Control passed to delegate objects to perform application specific behavior
    Avoids need to subclass complex objects
    Many UIKit classes use delegates
        -UIApplication
        - UITableView
        - UITextField

UIApplicationDelegate
    XCode project templates have one set up by default
    Object you provide that participates in application lifecycle
    Can implement various methods which UIApplication will call

Info.plist file
    Property List (XML) describing your application
        - Icon appearance
        - Status bar style
        - Orientation, uses WiFi, system requirements
    Can edit most properties in XCode

Model View Controller
    Controller is the intermediary between the Model and View
    View - UI
    Model - where the data is stored
    Outlets and actions are how the Controller, Model, and View communicate with each other

Nib Files - design time
    Helps you design the View
    add controller objects

HelloPolly
    Designed to help us understand the MVC application architecture
IPhone
0 Comment(s) Add comment
 
Mac OS Getters and Setters and what you're used to Tuesday, March 09, 2010 2:02 PM
I ran into a bit of a problem the other day with using setters and getters. I figured I would use the Object C syntax to set a property. Something like this:

[someThing someProperty:10];

The compiler kept giving me some vague error message and I kept on looking at it. Eventually, I ran across a blog entry which clued me in. If I wanted to something like this, I had to use:

[someThing setsomeProperty:10];

The blog entry was interesting because it was actually talking about using dot notation for setting properties in Objective C. It suggested that instead of using what it called the obvious:

someThing.setsomeProperty = 10;

That you should use the less obvious:

someThing.someProperty = 10;

Coming from .NET programming, the second way to use the dot notation is what I would have thought was pretty obvious. The inclusion of "set" in the property name was not very obvious to me. I guess it's all in where you're coming from.
IPhone
0 Comment(s) Add comment
 
My First IPhone application Thursday, March 04, 2010 8:27 PM
I downloaded the IPhone SDK and associated tools and built my first IPhone application. It doesn't do anything much besides display some text and show a picture. So far, it reminds me a bit of Visual Basic.
IPhone
0 Comment(s) Add comment
 
IPhone Development Thursday, March 04, 2010 7:19 PM
IPhone development
  • Tools - XCode and Interface Builder
  • Foundation and UIKit
  • Objective C (runtime?)
Mac OS X consists of
  • Foundation
  • Media
  • Core Services
  • Core OS
The IPhone OS is comprised of the same elements, except Cocoa Touch.
IPhone
0 Comment(s) Add comment
 
Remember to add IPhone dev to website Friday, February 26, 2010 10:41 PM
As I come up to speed on IPhone and all things Mac, I'll have to be sure to rework that information into this website. I've kinda sorta started to by adding the Mac and IPhone blog categories.
IPhone
0 Comment(s) Add comment
 
Stanford Course Friday, February 26, 2010 10:40 PM
To come up to speed on IPhone development, I will work my way through the Stanford IPhone development course CS193P. The syllabus looks like this:

Week 1: 1/5 & 1/7
1/5: Intro to Mac OS X and Cocoa Touch, Objective-C and Tools
1/7: Using Objective-C, Foundation objects
Assignment: Hello Stanford and Command Line Tool I (due 1/13)
Week 2: 1/12 & 1/14
1/12: Custom classes, Memory Management, ObjC Properties
1/14: MVC, Interface Builder, Controls & target-action
Assignment: Command Line Tool II and HelloPoly I (due 1/20)
Week 3: 1/19 & 1/21
1/19: Views, Animation, Open GL
1/21: View Controllers
Assignment: HelloPoly II (due 1/27)
Week 4: 1/26 & 1/28
1/26: Navigation Controllers, Tab Bar Controllers, Searching
1/28: TableViews
Assignment: Flickr 1 (due 2/3)
Week 5: 2/2 & 2/4
2/2: Dealing with Data: User Defaults, SQLite, Web Services
2/4: Threading, Notifications, KVC
Assignment: Flickr 2 (due 2/10), Final project proposals
Week 6: 2/9 & 2/11
2/9: Text, Responders, Modal Views
2/11: Address Book
Assignment: Flickr 3 (due 2/17)
Week 7: 2/16 & 2/18
2/16: WebViews, MapKit
2/18: Multitouch, Gestures
Assignment: Flickr 4 (due 2/24)
Week 8: 2/23 & 2/25
2/23: Device APIs: Location, Accelerometer, Compass, Battery Life
2/25: Audio playback, Video playback, Image/Video Picker, iPod Media Access
Assignment: Final project (due 3/17)
Week 9: 3/2 & 3/4
3/2: Bonjour, streams, networking, GameKit
3/9: Unit testing, Objective-C fun, localization
Assignment: Final project (due 3/17)
Week 10: 3/9 & 3/11
3/9: TBD
3/11: TBD
Assignment: Final project (due 3/17)
CS193P Handout #1
Winter 2010 Cannistraro/Shaffer

While I was on vacation I watched the first three classes or so. Looks like it's going to be fun!
IPhone
0 Comment(s) Add comment
 
I ordered the new Mac Friday, February 26, 2010 2:15 PM

I just ordered a new IMac from B&H Photo (free shipping - oh, not quite $15 and tax - significant here in WA - about $200). The specs are:

  • Quad-Core 2.66GHz Intel Core i5
  • 8GB (4x2GB) RAM
  • 1TB Hard Drive
  • 8x SuperDrive DVD Burner, SD Card Slot
  • ATI Radeon HD 4850 Graphics
  • 27" LED Backlit 16:9 Widescreen Display
  • iSight Camera, Bluetooth 2.1+EDR
  • 802.11n Airport Extreme Wi-Fi
  • Wireless Keyboard & Magic Mouse
  • Mac OS X 10.6 Snow Leopard
Who would have thought! Should be here next Friday!
IPhone
0 Comment(s) Add comment
 
A Mac Guy Once Again Saturday, February 20, 2010 5:02 PM

Before I came to work at Microsoft, I worked at OCLC (technically, Ameritech bought our division right before I left). I did a variety of things at OCLC but one of the projects I got involved with was a pilot Macintosh project. In 1987, or so, OCLC became a developer partner with Apple. As a result they got an Apple Lisa (a firmware upgrade later, the MacXL) and one of the very early Macintosh's. When OCLC ended its pilot program, they gave me the Lisa/MacXL. I've kept it all these years and it is now out in the garage.

Well, after all these years I've decided to buy a Mac. I'll keep everyone posted on the experience!

IPhone
0 Comment(s) Add comment
 
© LimberTech 2014