¡@

Home 

2014/10/15 ¤U¤È 10:15:31

iphone Programming Glossary: unsigned

Retrieving a pixel alpha value for a UIImage

http://stackoverflow.com/questions/1042830/retrieving-a-pixel-alpha-value-for-a-uiimage

from the UIImageView. int byteIndex bytesPerRow uiViewPoint.y uiViewPoint.x bytesPerPixel unsigned char alpha rawData byteIndex 3 However I don't get the values I expect. For a completely black transparent..

NSCalendar first day of week

http://stackoverflow.com/questions/1106943/nscalendar-first-day-of-week

NSCalendar alloc initWithCalendarIdentifier NSGregorianCalendar gregorian setFirstWeekday 0 unsigned unitFlags NSYearCalendarUnit NSMonthCalendarUnit NSDayCalendarUnit NSWeekCalendarUnit NSWeekdayCalendarUnit..

Best way to serialize a NSData into an hexadeximal string

http://stackoverflow.com/questions/1305225/best-way-to-serialize-a-nsdata-into-an-hexadeximal-string

hexadecimalString Returns hexadecimal string of NSData. Empty string if data is empty. const unsigned char dataBuffer const unsigned char self bytes if dataBuffer return NSString string NSUInteger dataLength.. hexadecimal string of NSData. Empty string if data is empty. const unsigned char dataBuffer const unsigned char self bytes if dataBuffer return NSString string NSUInteger dataLength self length NSMutableString.. dataLength 2 for int i 0 i dataLength i hexString appendString NSString stringWithFormat @ 02lx unsigned long dataBuffer i return NSString stringWithString hexString @end Usage NSData someData ... NSString..

How to get the RGB values for a pixel on an image on the iphone

http://stackoverflow.com/questions/144250/how-to-get-the-rgb-values-for-a-pixel-on-an-image-on-the-iphone

pixelData Read Only Data Previous information method 2 Step 1. I declared a type for byte typedef unsigned char byte Step 2. I declared a struct to correspond to a pixel typedef struct RGBPixel byte red byte..

MD5 algorithm in Objective C

http://stackoverflow.com/questions/1524604/md5-algorithm-in-objective-c

CC_MD5 access @implementation NSString MyExtensions NSString md5 const char cStr self UTF8String unsigned char result CC_MD5_DIGEST_LENGTH CC_MD5 cStr strlen cStr result This is the md5 call return NSString.. 11 result 12 result 13 result 14 result 15 @end @implementation NSData MyExtensions NSString md5 unsigned char result CC_MD5_DIGEST_LENGTH CC_MD5 self.bytes self.length result This is the md5 call return NSString..

OpenGL ES iPhone - drawing anti aliased lines

http://stackoverflow.com/questions/1813035/opengl-es-iphone-drawing-anti-aliased-lines

en us um people hoppe overdraw.pdf You could do something along this way Colors is a pointer to unsigned bytes 4 per color . Should alternate in opacity. glColorPointer 4 GL_UNSIGNED_BYTE 0 colors glEnableClientState..

Objective-c iPhone percent encode a string?

http://stackoverflow.com/questions/3423545/objective-c-iphone-percent-encode-a-string

characters. NSString URLEncodedString_ch NSMutableString output NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i.. URLEncodedString_ch NSMutableString output NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned.. char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned char thisChar source i if thisChar ' ' output appendString @ else if thisChar '.' thisChar ' ' thisChar..

iPhone Unzip code

http://stackoverflow.com/questions/412982/iphone-unzip-code

@ test.txt gzFile file gzopen path UTF8String rb FILE dest fopen unzipeddest UTF8String w unsigned char buffer CHUNK int uncompressedLength gzread file buffer CHUNK if fwrite buffer 1 uncompressedLength..

When to use NSInteger vs int?

http://stackoverflow.com/questions/4445173/when-to-use-nsinteger-vs-int

TARGET_OS_IPHONE TARGET_OS_WIN32 NS_BUILD_32_LIKE_64 typedef long NSInteger typedef unsigned long NSUInteger #else typedef int NSInteger typedef unsigned int NSUInteger #endif With regard to the.. typedef long NSInteger typedef unsigned long NSUInteger #else typedef int NSInteger typedef unsigned int NSUInteger #endif With regard to the correct format specifier you should use for each of these types..

How do I create delegates in Objective-C?

http://stackoverflow.com/questions/626898/how-do-i-create-delegates-in-objective-c

@property nonatomic weak id SomethingDelegate delegate @end @implementation Something struct unsigned int didFinishLoadingItem 1 unsigned int didFailWithError 1 delegateRespondsTo @synthesize delegate void.. delegate @end @implementation Something struct unsigned int didFinishLoadingItem 1 unsigned int didFailWithError 1 delegateRespondsTo @synthesize delegate void setDelegate id JSSomethingDelegate..

How can I programmatically get the MAC address of an iphone

http://stackoverflow.com/questions/677530/how-can-i-programmatically-get-the-mac-address-of-an-iphone

GetIPAddresses GetHWAddresses int i NSString deviceIP nil for i 0 i MAXADDRS i static unsigned long localHost 0x7F000001 127.0.0.1 unsigned long theAddr theAddr ip_addrs i if theAddr 0 break if theAddr.. i NSString deviceIP nil for i 0 i MAXADDRS i static unsigned long localHost 0x7F000001 127.0.0.1 unsigned long theAddr theAddr ip_addrs i if theAddr 0 break if theAddr localHost continue NSLog @ Name s MAC..

URL encode an NSString

http://stackoverflow.com/questions/8088473/url-encode-an-nsstring

NSString NSString_Extended NSString urlencode NSMutableString output NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i.. NSString urlencode NSMutableString output NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned.. char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned char thisChar source i if thisChar ' ' output appendString @ else if thisChar '.' thisChar ' ' thisChar..

Retrieving a pixel alpha value for a UIImage

http://stackoverflow.com/questions/1042830/retrieving-a-pixel-alpha-value-for-a-uiimage

the array index for the given alpha channel using the coordinates from the UIImageView. int byteIndex bytesPerRow uiViewPoint.y uiViewPoint.x bytesPerPixel unsigned char alpha rawData byteIndex 3 However I don't get the values I expect. For a completely black transparent area of the image I get non zero values for the alpha..

NSCalendar first day of week

http://stackoverflow.com/questions/1106943/nscalendar-first-day-of-week

would be 7 instead of rolling over to 0 NSCalendar gregorian NSCalendar alloc initWithCalendarIdentifier NSGregorianCalendar gregorian setFirstWeekday 0 unsigned unitFlags NSYearCalendarUnit NSMonthCalendarUnit NSDayCalendarUnit NSWeekCalendarUnit NSWeekdayCalendarUnit NSDateComponents todaysDate gregorian components unitFlags..

Best way to serialize a NSData into an hexadeximal string

http://stackoverflow.com/questions/1305225/best-way-to-serialize-a-nsdata-into-an-hexadeximal-string

NSData NSData_Conversion #pragma mark String Conversion NSString hexadecimalString Returns hexadecimal string of NSData. Empty string if data is empty. const unsigned char dataBuffer const unsigned char self bytes if dataBuffer return NSString string NSUInteger dataLength self length NSMutableString hexString NSMutableString.. mark String Conversion NSString hexadecimalString Returns hexadecimal string of NSData. Empty string if data is empty. const unsigned char dataBuffer const unsigned char self bytes if dataBuffer return NSString string NSUInteger dataLength self length NSMutableString hexString NSMutableString stringWithCapacity dataLength 2.. NSMutableString hexString NSMutableString stringWithCapacity dataLength 2 for int i 0 i dataLength i hexString appendString NSString stringWithFormat @ 02lx unsigned long dataBuffer i return NSString stringWithString hexString @end Usage NSData someData ... NSString someDataHexadecimalString someData hexadecimalString This is..

How to get the RGB values for a pixel on an image on the iphone

http://stackoverflow.com/questions/144250/how-to-get-the-rgb-values-for-a-pixel-on-an-image-on-the-iphone

pixelData RGBAPixel CGBitmapContextGetData context return pixelData Read Only Data Previous information method 2 Step 1. I declared a type for byte typedef unsigned char byte Step 2. I declared a struct to correspond to a pixel typedef struct RGBPixel byte red byte green byte blue RGBPixel Step 3. I subclassed UIImageView and..

MD5 algorithm in Objective C

http://stackoverflow.com/questions/1524604/md5-algorithm-in-objective-c

#import CommonCrypto CommonDigest.h Need to import for CC_MD5 access @implementation NSString MyExtensions NSString md5 const char cStr self UTF8String unsigned char result CC_MD5_DIGEST_LENGTH CC_MD5 cStr strlen cStr result This is the md5 call return NSString stringWithFormat @ 02x 02x 02x 02x 02x 02x 02x 02x 02x 02x.. 5 result 6 result 7 result 8 result 9 result 10 result 11 result 12 result 13 result 14 result 15 @end @implementation NSData MyExtensions NSString md5 unsigned char result CC_MD5_DIGEST_LENGTH CC_MD5 self.bytes self.length result This is the md5 call return NSString stringWithFormat @ 02x 02x 02x 02x 02x 02x 02x 02x 02x..

OpenGL ES iPhone - drawing anti aliased lines

http://stackoverflow.com/questions/1813035/opengl-es-iphone-drawing-anti-aliased-lines

can read a paper about this here http research.microsoft.com en us um people hoppe overdraw.pdf You could do something along this way Colors is a pointer to unsigned bytes 4 per color . Should alternate in opacity. glColorPointer 4 GL_UNSIGNED_BYTE 0 colors glEnableClientState GL_COLOR_ARRAY points is a pointer to floats 2 per..

Objective-c iPhone percent encode a string?

http://stackoverflow.com/questions/3423545/objective-c-iphone-percent-encode-a-string

specification . It will also properly handle encoding unicode characters. NSString URLEncodedString_ch NSMutableString output NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned char thisChar source i if thisChar.. also properly handle encoding unicode characters. NSString URLEncodedString_ch NSMutableString output NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned char thisChar source i if thisChar ' ' output appendString.. NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned char thisChar source i if thisChar ' ' output appendString @ else if thisChar '.' thisChar ' ' thisChar '_' thisChar '~' thisChar 'a' thisChar 'z' thisChar..

iPhone Unzip code

http://stackoverflow.com/questions/412982/iphone-unzip-code

NSString unzipeddest DOCUMENTS_FOLDER stringByAppendingPathComponent @ test.txt gzFile file gzopen path UTF8String rb FILE dest fopen unzipeddest UTF8String w unsigned char buffer CHUNK int uncompressedLength gzread file buffer CHUNK if fwrite buffer 1 uncompressedLength dest uncompressedLength ferror dest NSLog @ error writing..

When to use NSInteger vs int?

http://stackoverflow.com/questions/4445173/when-to-use-nsinteger-vs-int

these types and they are defined like this #if __LP64__ TARGET_OS_EMBEDDED TARGET_OS_IPHONE TARGET_OS_WIN32 NS_BUILD_32_LIKE_64 typedef long NSInteger typedef unsigned long NSUInteger #else typedef int NSInteger typedef unsigned int NSUInteger #endif With regard to the correct format specifier you should use for each of these.. TARGET_OS_IPHONE TARGET_OS_WIN32 NS_BUILD_32_LIKE_64 typedef long NSInteger typedef unsigned long NSUInteger #else typedef int NSInteger typedef unsigned int NSUInteger #endif With regard to the correct format specifier you should use for each of these types see the String Programming Guide's section on Platform..

How do I create delegates in Objective-C?

http://stackoverflow.com/questions/626898/how-do-i-create-delegates-in-objective-c

didFailWithError NSError error @end @interface Something NSObject @property nonatomic weak id SomethingDelegate delegate @end @implementation Something struct unsigned int didFinishLoadingItem 1 unsigned int didFailWithError 1 delegateRespondsTo @synthesize delegate void setDelegate id JSSomethingDelegate aDelegate if delegate.. @interface Something NSObject @property nonatomic weak id SomethingDelegate delegate @end @implementation Something struct unsigned int didFinishLoadingItem 1 unsigned int didFailWithError 1 delegateRespondsTo @synthesize delegate void setDelegate id JSSomethingDelegate aDelegate if delegate aDelegate delegate aDelegate delegateRespondsTo.didFinishLoadingItem..

How can I programmatically get the MAC address of an iphone

http://stackoverflow.com/questions/677530/how-can-i-programmatically-get-the-mac-address-of-an-iphone

cleaned things up. IPAddress.h IPAddress.c And to use it InitAddresses GetIPAddresses GetHWAddresses int i NSString deviceIP nil for i 0 i MAXADDRS i static unsigned long localHost 0x7F000001 127.0.0.1 unsigned long theAddr theAddr ip_addrs i if theAddr 0 break if theAddr localHost continue NSLog @ Name s MAC s IP s n if_names.. And to use it InitAddresses GetIPAddresses GetHWAddresses int i NSString deviceIP nil for i 0 i MAXADDRS i static unsigned long localHost 0x7F000001 127.0.0.1 unsigned long theAddr theAddr ip_addrs i if theAddr 0 break if theAddr localHost continue NSLog @ Name s MAC s IP s n if_names i hw_addrs i ip_names i decided what adapter..

URL encode an NSString

http://stackoverflow.com/questions/8088473/url-encode-an-nsstring

using this category to url encode a string @implementation NSString NSString_Extended NSString urlencode NSMutableString output NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned char thisChar source i if thisChar.. encode a string @implementation NSString NSString_Extended NSString urlencode NSMutableString output NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned char thisChar source i if thisChar ' ' output appendString.. NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned char thisChar source i if thisChar ' ' output appendString @ else if thisChar '.' thisChar ' ' thisChar '_' thisChar '~' thisChar 'a' thisChar 'z' thisChar..

Retrieving a pixel alpha value for a UIImage

http://stackoverflow.com/questions/1042830/retrieving-a-pixel-alpha-value-for-a-uiimage

using the coordinates from the UIImageView. int byteIndex bytesPerRow uiViewPoint.y uiViewPoint.x bytesPerPixel unsigned char alpha rawData byteIndex 3 However I don't get the values I expect. For a completely black transparent area of the image..

NSCalendar first day of week

http://stackoverflow.com/questions/1106943/nscalendar-first-day-of-week

to 0 NSCalendar gregorian NSCalendar alloc initWithCalendarIdentifier NSGregorianCalendar gregorian setFirstWeekday 0 unsigned unitFlags NSYearCalendarUnit NSMonthCalendarUnit NSDayCalendarUnit NSWeekCalendarUnit NSWeekdayCalendarUnit NSDateComponents..

Best way to serialize a NSData into an hexadeximal string

http://stackoverflow.com/questions/1305225/best-way-to-serialize-a-nsdata-into-an-hexadeximal-string

Conversion NSString hexadecimalString Returns hexadecimal string of NSData. Empty string if data is empty. const unsigned char dataBuffer const unsigned char self bytes if dataBuffer return NSString string NSUInteger dataLength self length NSMutableString.. Returns hexadecimal string of NSData. Empty string if data is empty. const unsigned char dataBuffer const unsigned char self bytes if dataBuffer return NSString string NSUInteger dataLength self length NSMutableString hexString NSMutableString.. stringWithCapacity dataLength 2 for int i 0 i dataLength i hexString appendString NSString stringWithFormat @ 02lx unsigned long dataBuffer i return NSString stringWithString hexString @end Usage NSData someData ... NSString someDataHexadecimalString..

How to get the RGB values for a pixel on an image on the iphone

http://stackoverflow.com/questions/144250/how-to-get-the-rgb-values-for-a-pixel-on-an-image-on-the-iphone

context return pixelData Read Only Data Previous information method 2 Step 1. I declared a type for byte typedef unsigned char byte Step 2. I declared a struct to correspond to a pixel typedef struct RGBPixel byte red byte green byte blue RGBPixel..

MD5 algorithm in Objective C

http://stackoverflow.com/questions/1524604/md5-algorithm-in-objective-c

Need to import for CC_MD5 access @implementation NSString MyExtensions NSString md5 const char cStr self UTF8String unsigned char result CC_MD5_DIGEST_LENGTH CC_MD5 cStr strlen cStr result This is the md5 call return NSString stringWithFormat @.. 9 result 10 result 11 result 12 result 13 result 14 result 15 @end @implementation NSData MyExtensions NSString md5 unsigned char result CC_MD5_DIGEST_LENGTH CC_MD5 self.bytes self.length result This is the md5 call return NSString stringWithFormat..

OpenGL ES iPhone - drawing anti aliased lines

http://stackoverflow.com/questions/1813035/opengl-es-iphone-drawing-anti-aliased-lines

research.microsoft.com en us um people hoppe overdraw.pdf You could do something along this way Colors is a pointer to unsigned bytes 4 per color . Should alternate in opacity. glColorPointer 4 GL_UNSIGNED_BYTE 0 colors glEnableClientState GL_COLOR_ARRAY..

Objective-c iPhone percent encode a string?

http://stackoverflow.com/questions/3423545/objective-c-iphone-percent-encode-a-string

handle encoding unicode characters. NSString URLEncodedString_ch NSMutableString output NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned.. NSString URLEncodedString_ch NSMutableString output NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned char thisChar source.. char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned char thisChar source i if thisChar ' ' output appendString @ else if thisChar '.' thisChar ' ' thisChar '_' thisChar '~'..

iPhone Unzip code

http://stackoverflow.com/questions/412982/iphone-unzip-code

@ test.txt gzFile file gzopen path UTF8String rb FILE dest fopen unzipeddest UTF8String w unsigned char buffer CHUNK int uncompressedLength gzread file buffer CHUNK if fwrite buffer 1 uncompressedLength dest uncompressedLength..

When to use NSInteger vs int?

http://stackoverflow.com/questions/4445173/when-to-use-nsinteger-vs-int

#if __LP64__ TARGET_OS_EMBEDDED TARGET_OS_IPHONE TARGET_OS_WIN32 NS_BUILD_32_LIKE_64 typedef long NSInteger typedef unsigned long NSUInteger #else typedef int NSInteger typedef unsigned int NSUInteger #endif With regard to the correct format specifier.. NS_BUILD_32_LIKE_64 typedef long NSInteger typedef unsigned long NSUInteger #else typedef int NSInteger typedef unsigned int NSUInteger #endif With regard to the correct format specifier you should use for each of these types see the String..

How do I create delegates in Objective-C?

http://stackoverflow.com/questions/626898/how-do-i-create-delegates-in-objective-c

Something NSObject @property nonatomic weak id SomethingDelegate delegate @end @implementation Something struct unsigned int didFinishLoadingItem 1 unsigned int didFailWithError 1 delegateRespondsTo @synthesize delegate void setDelegate id JSSomethingDelegate.. nonatomic weak id SomethingDelegate delegate @end @implementation Something struct unsigned int didFinishLoadingItem 1 unsigned int didFailWithError 1 delegateRespondsTo @synthesize delegate void setDelegate id JSSomethingDelegate aDelegate if delegate..

How can I programmatically get the MAC address of an iphone

http://stackoverflow.com/questions/677530/how-can-i-programmatically-get-the-mac-address-of-an-iphone

And to use it InitAddresses GetIPAddresses GetHWAddresses int i NSString deviceIP nil for i 0 i MAXADDRS i static unsigned long localHost 0x7F000001 127.0.0.1 unsigned long theAddr theAddr ip_addrs i if theAddr 0 break if theAddr localHost continue.. GetHWAddresses int i NSString deviceIP nil for i 0 i MAXADDRS i static unsigned long localHost 0x7F000001 127.0.0.1 unsigned long theAddr theAddr ip_addrs i if theAddr 0 break if theAddr localHost continue NSLog @ Name s MAC s IP s n if_names i..

URL encode an NSString

http://stackoverflow.com/questions/8088473/url-encode-an-nsstring

@implementation NSString NSString_Extended NSString urlencode NSMutableString output NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned.. NSString_Extended NSString urlencode NSMutableString output NSMutableString string const unsigned char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned char thisChar source.. char source const unsigned char self UTF8String int sourceLen strlen const char source for int i 0 i sourceLen i const unsigned char thisChar source i if thisChar ' ' output appendString @ else if thisChar '.' thisChar ' ' thisChar '_' thisChar '~'..