iPhone developement – Beginner’s Tutorials

Part 1:  Kickoff iPhone Development
This presentation tells the environment requirements and basic necessities to start with iPhone App Development.

Part 2: A Closer Look
This session will give a brief introduction to memory management and a closer look to APIs and components

Part 3: More than UI
This session deals with the APIs in Foundation framework.

Horizontal UIPickerView

A situation can arise when you want to have some horizontal UIPickerView in your application.

Something like what in the picture shown below


Following code will draw one like that..

// Write code to create self.view
// Then...
pickerViewArray = [[NSArray arrayWithObjects:
 @"John Appleseed", @"Chris Armstrong", @"Serena Auroux",
 @"Susan Bean", @"Luis Becerra", @"Kate Bell", @"Alain Briere",
 nil] retain];
 myPickerView = [[UIPickerView alloc] initWithFrame:CGRectZero];
 myPickerView.delegate = self;
 myPickerView.showsSelectionIndicator =YES;
 myPickerView.backgroundColor = [UIColor clearColor];
 CGAffineTransform rotate = CGAffineTransformMakeRotation(-3.14/2);
 rotate = CGAffineTransformScale(rotate, 0.25, 2.0);
 [self.myPickerView setTransform:rotate];
 [self.view addSubview:myPickerView];

// UIPickerViewDelegate

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
	CGRect rect = CGRectMake(0, 0, 120, 80);
	UILabel *label = [[UILabel alloc]initWithFrame:rect];
	CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14/2);
	rotate = CGAffineTransformScale(rotate, 0.25, 2.0);
	[label setTransform:rotate];
	label.text = [pickerViewArray objectAtIndex:row];
	label.font = [UIFont systemFontOfSize:22.0];
	label.textAlignment = UITextAlignmentCenter;
	label.numberOfLines = 2;
	label.lineBreakMode = UILineBreakModeWordWrap;
	label.backgroundColor = [UIColor clearColor];
	label.clipsToBounds = YES;
	return label ;

Courtesy: Syed Yusuf

Email syntax validation -iPhone Programming

Understanding that iPhone SDK dont support NSPredicate which is there for MAC Apps SDK i wrote an Utility Method to do a syntax validation of email.


if( (0 != [email rangeOfString:@"@"].length) &&  (0 != [email rangeOfString:@"."].length) )
		NSMutableCharacterSet *invalidCharSet = [[[[NSCharacterSet alphanumericCharacterSet] invertedSet]mutableCopy]autorelease];
		[invalidCharSet removeCharactersInString:@"_-"];

		NSRange range1 = [email rangeOfString:@"@" options:NSCaseInsensitiveSearch];

		// If username part contains any character other than "."  "_" "-"

		NSString *usernamePart = [email substringToIndex:range1.location];
		NSArray *stringsArray1 = [usernamePart componentsSeparatedByString:@"."];
		for (NSString *string in stringsArray1) {
			NSRange rangeOfInavlidChars=[string rangeOfCharacterFromSet: invalidCharSet];
			if(rangeOfInavlidChars.length !=0 || [string isEqualToString:@""])
				return NO;

		NSString *domainPart = [email substringFromIndex:range1.location+1];
		NSArray *stringsArray2 = [domainPart componentsSeparatedByString:@"."];

		for (NSString *string in stringsArray2) {
			NSRange rangeOfInavlidChars=[string rangeOfCharacterFromSet:invalidCharSet];
			if(rangeOfInavlidChars.length !=0 || [string isEqualToString:@""])
				return NO;

		return YES;
	else // no '@' or '.' present
		return NO;