Posts

Showing posts from November, 2014

Struck through text in UILabel

In iOS 6.0 and up UILabel supports NSAttributedString NSMutableAttributedString * attributeString = [[ NSMutableAttributedString alloc ] initWithString :@ "Your String here" ]; [ attributeString addAttribute : NSStrikethroughStyleAttributeName value :@ 2 range : NSMakeRange ( 0 , [ attributeString length ])]; Definition : - ( void ) addAttribute :( NSString *) name value :( id ) value range :( NSRange ) aRange Parameters List: name : A string specifying the attribute name. Attribute keys can be supplied by another framework or can be custom ones you define. For information about where to find the system-supplied attribute keys, see the overview section in NSAttributedString Class Reference. value : The attribute value associated with name. aRange : The range of characters to which the specified attribute/value pair applies. Then yourLabel . attributedText = attributeString ;

Add one minutes in NSDate

You can use dateByAddingTimeInterval. NSDate *currentDate = [NSDate date]; NSDate *date_plus_one_minute = [currentDate dateByAddingTimeInterval:60]; //60 seconds

Decode a UTF8 encoded NSString

While programming in iOS sometime we have to hit certain URLs which in turn returns Encoded string.Which we have to decode to get the actual string. NSString *currentEncodedString =@"%3CTom%26Jerry%3E"; //Received Encoded UTF8 String NSString *currentDecodedString = [currentEncodedString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSLog(@"My Current Decoded String: %@",currentDecodedString);