Friday, September 24, 2010

The Learning Center App

App Description: The Learning Center is the Ultimate tool to assist your child in learning there letters, numbers, and Words. This Tab-Based App is designed to entertain your child while learning there ABC'S, 123'S, and even simple words. Recommended by Oprah the Learning Center will have you child ready for Pre-school and/or Kindergarden.



Friday, September 10, 2010

Operators in Objective C.

Operator
Function
+
Addition
-
Substraction
/
Division
*
Multiplication
%
Modulus



Relational operators
Operator
Function
>
Greater then
>=
Greater then or equal to
==
Equal to
!=
Not equal to
<=
Less then or equal to
<
Less then


Logical operators
Operator
Function
&&
AND
||
OR
!
NOT

Sunday, September 5, 2010

Arrays in XCODE 3.2.3 and IPHONE SDK 4

How to create an Array:

To create an Array with the name testArray do the following:

NSArray *testArray = [[NSArray alloc] init];

The Array called  an empty array.

Add something to the array
[testArray addObject:someObject];
[testArray addObject:someOtherObject];

// Get stuff out of the array
NSObject *anObject = [testArray objectAtIndex:0];

// Loop through contents of array
for (NSObject *anObject in testArray) {
     
}

// Remove from array
[testArray removeObjectAtIndex:1];

Saturday, September 4, 2010

How to send a Variable to an UILAERTVIEW

In this example there is a variable called Score in the program. You want to display the user's Score in a UIAlertview. User the following code.

NSString* messageString = [NSString stringWithFormat: @"End of Test. Your Score is: %d", Score]; 
UIAlertView *alert = [[UIAlertView alloc
initWithTitle:@"Final Score" 
message:messageString
delegate:self 
cancelButtonTitle:@"Continue" 
otherButtonTitles:nil];
[alert show];
[alert release];


Thursday, September 2, 2010

How to add Paint feature to your IPHONE App...

Add the following code to the .h file that you want to paint on.


UIImageView *drawImage;
int mouseMoved;
BOOL mouseSwiped;
CGPoint lastPoint;

Add the following code to the .m file that you want to paint on.

- (void)viewDidLoad {
    [super viewDidLoad];

// New code for Drawing App. Delete if it does not work.
drawImage = [[UIImageView alloc] initWithImage:nil];
drawImage.frame = self.view.frame;
[self.view addSubview:drawImage];
mouseMoved = 0;

}


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
mouseSwiped = NO;
UITouch *touch = [touches anyObject];
if ([touch tapCount] == 2) {
drawImage.image = nil;
return;
}
lastPoint = [touch locationInView:self.view];
lastPoint.y -= 20;
}


- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
mouseSwiped = YES;
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];
currentPoint.y -= 20; // only for 'kCGLineCapRound'
UIGraphicsBeginImageContext(self.view.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
mouseMoved++;
if (mouseMoved == 10) {
mouseMoved = 0;
}
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
if ([touch tapCount] == 2) {
drawImage.image = nil;
return;
}
if(!mouseSwiped) {
//if color == green
UIGraphicsBeginImageContext(self.view.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)]; //originally self.frame.size.width, self.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); //kCGLineCapSquare, kCGLineCapButt, kCGLineCapRound
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 1.0, 0.0, 1.0);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
}

Can some help me make a clear button to wipe ? E-mail timbojill@gmail.com. I do not read posts.



Friday, August 27, 2010

UIWebView Tutorial

In this tutorial I will explain how to create a UIWebView. The most common use of a UIWebView is to make your very own Safari Browser. So lets begin. The first thing you do is create a new project. Then in the .h file

Apple's Documentation on UIWebViews:

http://developer.apple.com/iphone/library/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html






This code has been test in XCODE 3.2.3 and IPHONE SDK 4.00.

If anyone has a better way of doing this please send an e-mail to timbojill@gmail.com. I do not read comments left behind by users.

UIAlertView Tutorial AKA Popup Message in XCODE.

This is how you create an UIAlertView AKA Popup message in XCODE.

UIAlertView *alert = [[UIAlertView alloc]

initWithTitle:@"Message Title"
message:@"You Message ."
delegate:self
cancelButtonTitle:@"Continue"
otherButtonTitles:nil];
[alert show];
[alert release];

This code has been test in XCODE 3.2.3 and IPHONE SDK 4.00.
If anyone has a better way of doing this please send an e-mail to timbojill@gmail.com. I do not read comments left behind by users.

How to add a delay of Timer between the execution of two lines of code in XCODE...

In this tutorial I am going to demenstrate how to add a Timer or delay between the execution of two lines of code. For example lets say you have one button and one UILABEL in a your xcode project. When the user clicks on the button it is to do the following:

1.)  send the variable dice to the UILABEL
2.) Two seconds later it will clear the text on the label.

This is how I have gotten this accomplished.

I have an IBACTION called randomNumber that I have linked to the button in my project.


-(IBAction)randomNumber {
int dice = 1 + arc4random() % (20);
label.text = [NSString stringWithFormat:@"%d", dice];
// perform selector after delay
[self performSelector:@selector(ClearLabel) withObject:nil afterDelay:2];

}

- (void)ClearLabel 

{
label.text = @"";
}

This code has been test in XCODE 3.2.3 and IPHONE SDK 4.00. 
If anyone has a better way of doing this please send an e-mail to timbojill@gmail.com. I do not read comments left behind by users

How to call a method AKA IBACTION in an XCODE project.

To call a Method or IBACTION in an XCODE project you have to use the following command.




[self methodname];




for example lets say you have the following methods AKA IBACTIONS in your .h file of you xcode project.




-(IBAction)method1;
-(IBAction)method2;

-(IBAction)method3;

-(IBAction)method4;





And you have all of them defined as following in your .M File of your XCODE project.


-(IBAction)method1

{

//do something

}







-(IBAction)method2


{


//do something


}









-(IBAction)method3


{


//do something


}









-(IBAction)method4


{


//do something


}
















Now for example if you want to call method2 from method1 you will do the following:







-(IBAction)method1


{


[self method2];






}






This is a fundamental concept in XCODE to understand.




This code has been test in XCODE 3.2.3 and IPHONE SDK 4.00.
If anyone has a better way of doing this please send an e-mail to timbojill@gmail.com. I do not read comments left behind by users.