NSString *questionableEmail = @"wtf";
NSString *emailRegEx = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegEx];
if ([emailTest evaluateWithObject:questionableEmail] == YES) {

NSLog(@"VALID EMAIL");

} else {

NSLog(@"FAILED EMAIL");

}

-(void)saveImageToTemporaryDirectory:(UIImage*)img {
NSLog(@"-(void)saveImageToTemp:(UIImage*)img {");

NSString *tmpDir = NSTemporaryDirectory();
NSString *directoryNameFileName = [tmpDir stringByAppendingPathComponent:@"TMPIMAGE.jpg"];

// AUTO ROTATES????
[UIImageJPEGRepresentation(img, 1.0) writeToFile:directoryNameFileName atomically:YES];

}

-(void)saveImageToDocumentsDirectory:(UIImage*)img {
NSLog(@"-(void)saveImageToDocuments:(UIImage*)img {");

NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDir = [documentPaths objectAtIndex:0];
NSString *directoryNameFileName = [documentsDir stringByAppendingPathComponent:@"SAVED_IMAGE.jpg"];

[UIImageJPEGRepresentation(img, 1.0) writeToFile:directoryNameFileName atomically:YES];

NSError *error;
NSFileManager *fileManager = [NSFileManager defaultManager];

NSLog(@"Documents: %@", [fileManager contentsOfDirectoryAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] error:&error]);

}

- (void)initWebView {
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
NSString *string = [NSString stringWithString:@"<html><body><h1>Lorem ipsum dolor sit amet</h1><p> Morbi ac imperdiet enim.</p></body></html>"];
[webView loadHTMLString:string baseURL:nil];
[self.view addSubview:webView];
[webView release];
}

- (void)viewDidLoad {

[self.textField setReturnKeyType:UIReturnKeyDone];
[self.textField addTarget:self
action:@selector(textFieldFinished:)
forControlEvents:UIControlEventEditingDidEndOnExit];

}

- (IBAction)textFieldFinished:(id)sender {
[sender resignFirstResponder];
}

- (void)viewDidLoad {
[txtInput addTarget:self action:@selector(onTextFieldDidChange) forControlEvents:UIControlEventEditingChanged];
}

-(void)onTextFieldDidChange {
NSLog(@” – txtInput = %@”,txtInput.text);
}

UITextView *questionText = [ [UITextView alloc ] initWithFrame:CGRectMake(5.0, 5.0, 300.0, 50.0) ];
questionText.textAlignment = UITextAlignmentLeft;
questionText.editable = NO;
questionText.scrollEnabled = NO;
questionText.textColor = [UIColor blackColor];
questionText.backgroundColor = [UIColor whiteColor];
questionText.font = [UIFont fontWithName:@"Helvetica" size:(12.0)];
[scrollView addSubview:questionText];
questionText.text = @"Appropriately parallel task next-generation applications through fully tested architectures. Uniquely coordinate professional outsourcing via fully tested mindshare";
[questionText release];

-(void)manageImageDirectories {

NSFileManager *filemgr = [NSFileManager defaultManager];
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];

NSString *ocFullDirPath = [NSString stringWithFormat:@"%@/OrangeCounty", documentsDir];

if ( ![filemgr fileExistsAtPath:ocFullDirPath isDirectory:YES] ) {
[filemgr createDirectoryAtPath:ocFullDirPath withIntermediateDirectories:NO attributes:nil error:nil];
}

}

-(BOOL)imageExists:(NSString*)imageName inThisDirectory:(NSString*)dirName {

NSFileManager *filemgr = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

// the documents directory plus whatever is in dirName then imageName
NSString *documentsDirectory = [NSString stringWithFormat:@"%@/%@",[paths objectAtIndex:0], dirName];

if ([filemgr fileExistsAtPath: [documentsDirectory stringByAppendingPathComponent:imageName] ] == YES) {

return YES;

} else {

return NO;

}

}


// toggle the I have accepted all your terms and conditions button
-(IBAction)actHasAccepted:(id)sender {
buttonHasAccepted.selected = !buttonHasAccepted.selected;
}

// the button that should trigger whatever
-(IBAction) doSomethingIfUserAgrees:(id) sender {

//
if (!buttonHasAccepted.selected) {

UIAlertView *alert =
[[UIAlertView alloc] initWithTitle: @"Error"
message: @"You must agree copy"
delegate: self
cancelButtonTitle: @"OK"
otherButtonTitles: nil];
[alert show];
[alert release];

} else {

// Carry on

}

}

UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];

CGRect frame = progressView.frame;
frame.size.width = 200;
frame.origin.x = 100;
frame.origin.y = 12;
progressView.frame = frame;
progressView.progress = 0.1f;

[self.view addSubview:progressView];

© 2012 James Border Suffusion theme by Sayontan Sinha