Objective C equivalent to javascripts setTimeout?

The performSelector: family has its limitations. Here is the closest setTimeout equivalent: dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * 0.5); dispatch_after(delay, dispatch_get_main_queue(), ^(void){ // do work in the UI thread here }); EDIT: A couple of projects that provide syntactic sugar and the ability to cancel execution (clearTimeout): https://github.com/Spaceman-Labs/Dispatch-Cancel https://gist.github.com/zwaldowski/955123

Objective C defining UIColor constants

A UIColor is not mutable. I usually do this with colors, fonts and images. You could easily modify it to use singletons or have a static initializer. @interface UIColor (MyProject) +(UIColor *) colorForSomePurpose; @end @implementation UIColor (MyProject) +(UIColor *) colorForSomePurpose { return [UIColor colorWithRed:0.6 green:0.8 blue:1.0 alpha:1.0]; } @end

urldecode in objective-c

I made a quick category to help resolve this 🙂 @interface NSString (stringByDecodingURLFormat) – (NSString *)stringByDecodingURLFormat; @end @implementation NSString – (NSString *)stringByDecodingURLFormat { NSString *result = [(NSString *)self stringByReplacingOccurrencesOfString:@”+” withString:@” “]; result = [result stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; return result; } @end Once defined, this quickly can handle an encoded string: NSString *decodedString = [myString stringByDecodingURLFormat]; Plenty of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)