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.