Monday 14 November 2011

How To Remove and Replace String within a String.

// Here We Deleting Something
NSString *content = @"foo/bar:baz.foo";
NSCharacterSet *deleteString = [NSCharacterSet characterSetWithCharactersInString:@"/:."];
content = [[content componentsSeparatedByCharactersInSet: deleteString] componentsJoinedByString: @""];
NSLog(@"String===>>>%@", content);

// Here We Replace Something
NSString *replaceString = @"This is a Dog";
replaceString = [replaceString stringByReplacingOccurrencesOfString:@"Dog" withString:@"Man"];
NSLog(@"Replace String===>>>%@", replaceString);

Friday 11 November 2011

How To Copying A String

NSMutableString *string1;
NSMutableString *string2;
string1 = [NSMutableString stringWithString: @"This is a string"];
string2 = string1;

How To Append A String Within A String

NSMutableString *string1;
NSMutableString *string2;
string1 = [NSMutableString stringWithString: @"This is a string"];
string2 = string1;
[string2 appendString: @" and it is mine!"];
NSLog (@"string1 = %@", string1);
NSLog (@"string2 = %@", string2);

How To Print The URl On The UIWebView

NSURL *url =[request URL];
NSString *urlStr =[url absoluteString];
NSLog(@"URL shouldStartLoadWithRequest===>>>%@",urlStr);

NSURL *url =[[webView request]URL];
NSString *urlStr =[url absoluteString];
NSLog(@"webViewDidStartLoad===>>>%@",urlStr);

NSURL *url =[[webView request]URL];
NSString *urlStr =[url absoluteString];
NSLog(@"webViewDidFinishLoad===>>>%@",urlStr);

How To Find The Current Date

NSDate *date = [NSDate date];
NSDateFormatter *formatter = [[[NSDateFormatter alloc]init]autorelease];
[formatter setDateFormat:@"HH:MM:SS"];
NSString* str =[formatter stringFromDate:date];
NSLog(str);
[timeLable setText:str];