Created
June 16, 2016 13:24
-
-
Save zhaoxiaobao/baaa93f706ff9cd1ca6496cdc3342019 to your computer and use it in GitHub Desktop.
stackoverflow-tag-objective-c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.How do I convert an NSString value to NSData? | |
NSString* str = @"teststring"; | |
NSData* data = [str dataUsingEncoding:NSUTF8StringEncoding]; | |
2.How to check iOS version? | |
[[UIDevice currentDevice].systemVersion floatValue] | |
3.How do I create delegates in Objective-C? | |
http://stackoverflow.com/questions/626898/how-do-i-create-delegates-in-objective-c | |
4.Location Services not working in iOS 8? | |
http://stackoverflow.com/questions/24062509/location-services-not-working-in-ios-8 | |
5.How do you trigger a block after a delay, like -performSelector:withObject:afterDelay:? | |
int parameter1 = 12; | |
float parameter2 = 144.1; | |
// Delay execution of my block for 10 seconds. | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ | |
NSLog(@"parameter1: %d parameter2: %f", parameter1, parameter2); | |
}); | |
let time1 = 8.23 | |
let time2 = 3.42 | |
// Delay 2 seconds | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(2.0 * Double(NSEC_PER_SEC))), dispatch_get_main_queue()) { () -> Void in | |
println("Sum of times: \(time1 + time2)") | |
} | |
+ (void)runBlock:(void (^)())block | |
{ | |
block(); | |
} | |
+ (void)runAfterDelay:(CGFloat)delay block:(void (^)())block | |
{ | |
void (^block_)() = [[block copy] autorelease]; | |
[self performSelector:@selector(runBlock:) withObject:block_ afterDelay:delay]; | |
} | |
[Util runAfterDelay:2 block:^{ | |
NSLog(@"two seconds later!"); | |
}]; | |
6.how to make a Placeholder in UITextView? | |
http://stackoverflow.com/questions/1328638/placeholder-in-uitextview | |
7.In Objective-C, how do I test the object type? | |
http://stackoverflow.com/questions/1144629/in-objective-c-how-do-i-test-the-object-type | |
8.UIView with rounded corners? | |
http://stackoverflow.com/questions/1509547/uiview-with-rounded-corners | |
9.How to print out the method name and line number and conditionally disable NSLog? | |
http://stackoverflow.com/questions/969130/how-to-print-out-the-method-name-and-line-number-and-conditionally-disable-nslog | |
10.How to check if an NSDictionary or NSMutableDictionary contains a key? | |
http://stackoverflow.com/questions/2784648/how-to-check-if-an-nsdictionary-or-nsmutabledictionary-contains-a-key | |
11.Is It Possible to NSLog C Structs (Like CGRect or CGPoint)? | |
http://stackoverflow.com/questions/550195/is-it-possible-to-nslog-c-structs-like-cgrect-or-cgpoint | |
12.Set the maximum character length of a UITextField? | |
http://stackoverflow.com/questions/433337/set-the-maximum-character-length-of-a-uitextfield | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment