-(NSString*) trimString:(NSString *)theString {
NSString *theStringTrimmed = [theString stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
return theStringTrimmed;
}
-(NSString *) removeNull:(NSString *) string {
NSRange range = [string rangeOfString:@"null"];
//NSLog(@"in removeNull : %d >>>> %@",range.length, string);
if (range.length > 0 || string == nil) {
string = @"";
}
string = [self trimString:string];
return string;
}
And call it like bellow...
NSString *str = yourStringValue;
str = [self removeNull:str];
No comments:
Post a Comment