This file contains hidden or 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
| /* Drawing a path in a custom UIView | |
| -(void)drawRect:(CGRect)rect | |
| { | |
| CGContextRect context = UIGraphicsGetCurrentContext(); | |
| CGContextBeginPath(context); | |
| CGContextMoveToPoint(context, 75, 10); | |
| CGContextAddLineToPoint(context, 160, 150); | |
| CGContextAddLineToPoint(context, 10, 150); |
This file contains hidden or 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
| /* | |
| Using arc4random() to get a floating point value between 0 and a given maximum value. Note that this produces a value that is double the precision of using rand(). | |
| */ | |
| -(double)randomValueFromZero:(double)toValue | |
| { | |
| return double val = floorf(((double)arc4random() / toValue) * 100.0f); | |
| } |
This file contains hidden or 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
| -(void)logAllKeys:(NSDictionary *)userInfo | |
| { | |
| NSArray *allKeys = [userInfo allKeys]; | |
| for (NSString *key in allKeys) { | |
| id value = [userInfo valueForKey:key]; | |
| NSString *valueString = @""; | |
| if ([value isKindOfClass:[NSString class]]) | |
| valueString = (NSString *)value; | |
| else if ([value isKindOfClass:[NSNumber class]]) |
This file contains hidden or 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
| #include <sys/socket.h> | |
| #include <sys/sysctl.h> | |
| #include <net/if.h> | |
| #include <net/if_dl.h> | |
| // From http://iphonedevelopertips.com/device/determine-mac-address.html | |
| - (NSString *)getMacAddress | |
| { | |
| int mgmtInfoBase[6]; |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <unistd.h> | |
| #include <sys/ioctl.h> | |
| #include <sys/types.h> | |
| #include <sys/socket.h> | |
| #include <netinet/in.h> | |
| #include <netdb.h> | |
| #include <arpa/inet.h> |
This file contains hidden or 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
| From UIView: if (self.window)… // I'm on screen | |
| From UIViewController: if (self.view.window)… |
This file contains hidden or 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
| CGRect screenBounds = [[UIScreen mainScreen] bounds]; // In points |
This file contains hidden or 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
| -(NSDate *)dateFromString:(NSString *)dateString; |
This file contains hidden or 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
| -(id)initWithSomething:(id)somethingIn | |
| { | |
| self = [self init]; | |
| self.something = somethingIn; | |
| return self; | |
| } |
This file contains hidden or 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
| if ([someObject conformsToProtocol:@protocol(NSCopying)]) … |