¡@

Home 

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

iphone Programming Glossary: utf8string

how to get the message when receiving the “kCTMessageReceivedNotification” notification on IOS5

http://stackoverflow.com/questions/10681995/how-to-get-the-message-when-receiving-the-kctmessagereceivednotification-notif

NSString text @ sqlite3 database if sqlite3_open @ private var mobile Library SMS sms.db UTF8String database SQLITE_OK sqlite3_stmt statement iOS 4 and 5 may require different SQL as the .db format may.. content char sqlite3_column_text statement 0 text NSString stringWithCString content encoding NSUTF8StringEncoding sqlite3_finalize statement sqlite3_close database return text Now make sure this app is installed..

How do I break down an NSTimeInterval into year, months, days, hours, minutes and seconds on iPhone?

http://stackoverflow.com/questions/1237778/how-do-i-break-down-an-nstimeinterval-into-year-months-days-hours-minutes-an

howLong NSString dateStr date description const char dateStrPtr dateStr UTF8String int year month day hour minute sec sscanf dateStrPtr d d d d d d year month day hour minute sec year..

How can I upload a photo to a server with the iPhone?

http://stackoverflow.com/questions/125306/how-can-i-upload-a-photo-to-a-server-with-the-iphone

data length 512 postData appendData NSString stringWithFormat @ @ r n boundry dataUsingEncoding NSUTF8StringEncoding postData appendData NSString stringWithFormat @ Content Disposition form data name @ filename.. Content Disposition form data name @ filename file.bin r n r n FORM_FLE_INPUT dataUsingEncoding NSUTF8StringEncoding postData appendData data postData appendData NSString stringWithFormat @ r n @ r n boundry dataUsingEncoding.. data postData appendData NSString stringWithFormat @ r n @ r n boundry dataUsingEncoding NSUTF8StringEncoding urlRequest setHTTPBody postData return urlRequest Uploader Private compress Uses zlib..

AES Encryption for an NSString on the iPhone

http://stackoverflow.com/questions/1400246/aes-encryption-for-an-nsstring-on-the-iphone

key @ my password NSString secret @ text to encrypt NSData plain secret dataUsingEncoding NSUTF8StringEncoding NSData cipher plain AES256EncryptWithKey key printf s n cipher description UTF8String plain.. NSUTF8StringEncoding NSData cipher plain AES256EncryptWithKey key printf s n cipher description UTF8String plain cipher AES256DecryptWithKey key printf s n plain description UTF8String printf s n NSString alloc.. n cipher description UTF8String plain cipher AES256DecryptWithKey key printf s n plain description UTF8String printf s n NSString alloc initWithData plain encoding NSUTF8StringEncoding UTF8String pool drain return..

MD5 algorithm in Objective C

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

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..

iPhone sending POST with NSURLConnection

http://stackoverflow.com/questions/2071788/iphone-sending-post-with-nsurlconnection

is my code const char bytes NSString stringWithFormat @ xml version 1.0 n mydata @ mydata data UTF8String NSURL url NSURL URLWithString @ http myurl.com script.php NSMutableURLRequest request NSMutableURLRequest.. xml charset utf 8 forHTTPHeaderField @ Content Type request setHTTPBody str dataUsingEncoding NSUTF8StringEncoding and on the server try the following PHP handle fopen php input rb http_raw_post_data '' while..

Objective-c iPhone percent encode a string?

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

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..

iPhone Unzip code

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

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.. @ 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..

iCloud basics and code sample [closed]

http://stackoverflow.com/questions/7795629/icloud-basics-and-code-sample

0 self.documentText NSString alloc initWithBytes contents bytes length contents length encoding NSUTF8StringEncoding else self.documentText @ NSLog @ UIDocument Loaded the following text from the cloud @ self.documentText.. the following text in the cloud @ self.documentText return NSData dataWithBytes self.documentText UTF8String length self.documentText length @end THE VIEWCONTROLLER ViewController.h iCloudText #import UIKit UIKit.h..

URL encode an NSString

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

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..

how to get the message when receiving the “kCTMessageReceivedNotification” notification on IOS5

http://stackoverflow.com/questions/10681995/how-to-get-the-message-when-receiving-the-kctmessagereceivednotification-notif

you should be able to see the message text NSString mostRecentSMS NSString text @ sqlite3 database if sqlite3_open @ private var mobile Library SMS sms.db UTF8String database SQLITE_OK sqlite3_stmt statement iOS 4 and 5 may require different SQL as the .db format may change const char sql4 SELECT text from message ORDER BY rowid.. SQLITE_ROW if sqlite3_step statement SQLITE_ROW char content char sqlite3_column_text statement 0 text NSString stringWithCString content encoding NSUTF8StringEncoding sqlite3_finalize statement sqlite3_close database return text Now make sure this app is installed in Applications . If you just build this app and install..

How do I break down an NSTimeInterval into year, months, days, hours, minutes and seconds on iPhone?

http://stackoverflow.com/questions/1237778/how-do-i-break-down-an-nstimeinterval-into-year-months-days-hours-minutes-an

now timeIntervalSinceDate then NSDate date NSDate dateWithTimeIntervalSince1970 howLong NSString dateStr date description const char dateStrPtr dateStr UTF8String int year month day hour minute sec sscanf dateStrPtr d d d d d d year month day hour minute sec year 1970 NSLog @ d years n d months n d days n d hours n d minutes..

How can I upload a photo to a server with the iPhone?

http://stackoverflow.com/questions/125306/how-can-i-upload-a-photo-to-a-server-with-the-iphone

Type NSMutableData postData NSMutableData dataWithCapacity data length 512 postData appendData NSString stringWithFormat @ @ r n boundry dataUsingEncoding NSUTF8StringEncoding postData appendData NSString stringWithFormat @ Content Disposition form data name @ filename file.bin r n r n FORM_FLE_INPUT dataUsingEncoding NSUTF8StringEncoding.. postData appendData NSString stringWithFormat @ Content Disposition form data name @ filename file.bin r n r n FORM_FLE_INPUT dataUsingEncoding NSUTF8StringEncoding postData appendData data postData appendData NSString stringWithFormat @ r n @ r n boundry dataUsingEncoding NSUTF8StringEncoding urlRequest setHTTPBody.. dataUsingEncoding NSUTF8StringEncoding postData appendData data postData appendData NSString stringWithFormat @ r n @ r n boundry dataUsingEncoding NSUTF8StringEncoding urlRequest setHTTPBody postData return urlRequest Uploader Private compress Uses zlib to compress the given data. Results The compressed data as..

AES Encryption for an NSString on the iPhone

http://stackoverflow.com/questions/1400246/aes-encryption-for-an-nsstring-on-the-iphone

argv NSAutoreleasePool pool NSAutoreleasePool alloc init NSString key @ my password NSString secret @ text to encrypt NSData plain secret dataUsingEncoding NSUTF8StringEncoding NSData cipher plain AES256EncryptWithKey key printf s n cipher description UTF8String plain cipher AES256DecryptWithKey key printf s n plain description.. secret @ text to encrypt NSData plain secret dataUsingEncoding NSUTF8StringEncoding NSData cipher plain AES256EncryptWithKey key printf s n cipher description UTF8String plain cipher AES256DecryptWithKey key printf s n plain description UTF8String printf s n NSString alloc initWithData plain encoding NSUTF8StringEncoding UTF8String.. NSData cipher plain AES256EncryptWithKey key printf s n cipher description UTF8String plain cipher AES256DecryptWithKey key printf s n plain description UTF8String printf s n NSString alloc initWithData plain encoding NSUTF8StringEncoding UTF8String pool drain return 0 Given this code and the fact that encrypted data will..

MD5 algorithm in Objective C

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

MyExtensions.h #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..

iPhone sending POST with NSURLConnection

http://stackoverflow.com/questions/2071788/iphone-sending-post-with-nsurlconnection

sending POST data to a PHP script with NSURLConnection. This is my code const char bytes NSString stringWithFormat @ xml version 1.0 n mydata @ mydata data UTF8String NSURL url NSURL URLWithString @ http myurl.com script.php NSMutableURLRequest request NSMutableURLRequest requestWithURL url request setHTTPMethod @ POST request.. request setHTTPMethod @ POST request setValue @ application xml charset utf 8 forHTTPHeaderField @ Content Type request setHTTPBody str dataUsingEncoding NSUTF8StringEncoding and on the server try the following PHP handle fopen php input rb http_raw_post_data '' while feof handle http_raw_post_data . fread handle 8192 fclose..

Objective-c iPhone percent encode a string?

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

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 @ else if thisChar..

iPhone Unzip code

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

stringByAppendingPathComponent @ sample.zip 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.. @ sample.zip 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..

iCloud basics and code sample [closed]

http://stackoverflow.com/questions/7795629/icloud-basics-and-code-sample

d typeName @ self.documentState typeName if contents length 0 self.documentText NSString alloc initWithBytes contents bytes length contents length encoding NSUTF8StringEncoding else self.documentText @ NSLog @ UIDocument Loaded the following text from the cloud @ self.documentText update textView in delegate... if _delegate respondsToSelector.. 0 self.documentText @ New Note NSLog @ UIDocument Will save the following text in the cloud @ self.documentText return NSData dataWithBytes self.documentText UTF8String length self.documentText length @end THE VIEWCONTROLLER ViewController.h iCloudText #import UIKit UIKit.h @class MyTextDocument @interface ViewController UIViewController..

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 sourceLen i const unsigned char thisChar source i if thisChar ' ' output appendString @ else if thisChar..

how to get the message when receiving the “kCTMessageReceivedNotification” notification on IOS5

http://stackoverflow.com/questions/10681995/how-to-get-the-message-when-receiving-the-kctmessagereceivednotification-notif

text NSString mostRecentSMS NSString text @ sqlite3 database if sqlite3_open @ private var mobile Library SMS sms.db UTF8String database SQLITE_OK sqlite3_stmt statement iOS 4 and 5 may require different SQL as the .db format may change const char.. SQLITE_ROW char content char sqlite3_column_text statement 0 text NSString stringWithCString content encoding NSUTF8StringEncoding sqlite3_finalize statement sqlite3_close database return text Now make sure this app is installed in Applications..

How do I break down an NSTimeInterval into year, months, days, hours, minutes and seconds on iPhone?

http://stackoverflow.com/questions/1237778/how-do-i-break-down-an-nstimeinterval-into-year-months-days-hours-minutes-an

date NSDate dateWithTimeIntervalSince1970 howLong NSString dateStr date description const char dateStrPtr dateStr UTF8String int year month day hour minute sec sscanf dateStrPtr d d d d d d year month day hour minute sec year 1970 NSLog @ d years..

How can I upload a photo to a server with the iPhone?

http://stackoverflow.com/questions/125306/how-can-i-upload-a-photo-to-a-server-with-the-iphone

dataWithCapacity data length 512 postData appendData NSString stringWithFormat @ @ r n boundry dataUsingEncoding NSUTF8StringEncoding postData appendData NSString stringWithFormat @ Content Disposition form data name @ filename file.bin r n r n FORM_FLE_INPUT.. stringWithFormat @ Content Disposition form data name @ filename file.bin r n r n FORM_FLE_INPUT dataUsingEncoding NSUTF8StringEncoding postData appendData data postData appendData NSString stringWithFormat @ r n @ r n boundry dataUsingEncoding NSUTF8StringEncoding.. postData appendData data postData appendData NSString stringWithFormat @ r n @ r n boundry dataUsingEncoding NSUTF8StringEncoding urlRequest setHTTPBody postData return urlRequest Uploader Private compress Uses zlib to compress the given..

How do I add a gradient to the text of a UILabel, but not the background?

http://stackoverflow.com/questions/1266179/how-do-i-add-a-gradient-to-the-text-of-a-uilabel-but-not-the-background

context kCGTextClip CGContextSetTextPosition context 0.0f round 20.0f 4.0f CGContextShowText context self.text UTF8String strlen self.text UTF8String CGContextClip context CGGradientRef gradient CGColorSpaceRef rgbColorspace size_t num_locations.. CGContextSetTextPosition context 0.0f round 20.0f 4.0f CGContextShowText context self.text UTF8String strlen self.text UTF8String CGContextClip context CGGradientRef gradient CGColorSpaceRef rgbColorspace size_t num_locations 2 CGFloat locations 2 0.0..

AES Encryption for an NSString on the iPhone

http://stackoverflow.com/questions/1400246/aes-encryption-for-an-nsstring-on-the-iphone

alloc init NSString key @ my password NSString secret @ text to encrypt NSData plain secret dataUsingEncoding NSUTF8StringEncoding NSData cipher plain AES256EncryptWithKey key printf s n cipher description UTF8String plain cipher AES256DecryptWithKey.. dataUsingEncoding NSUTF8StringEncoding NSData cipher plain AES256EncryptWithKey key printf s n cipher description UTF8String plain cipher AES256DecryptWithKey key printf s n plain description UTF8String printf s n NSString alloc initWithData plain.. key printf s n cipher description UTF8String plain cipher AES256DecryptWithKey key printf s n plain description UTF8String printf s n NSString alloc initWithData plain encoding NSUTF8StringEncoding UTF8String pool drain return 0 Given this code..

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..

iPhone sending POST with NSURLConnection

http://stackoverflow.com/questions/2071788/iphone-sending-post-with-nsurlconnection

NSURLConnection. This is my code const char bytes NSString stringWithFormat @ xml version 1.0 n mydata @ mydata data UTF8String NSURL url NSURL URLWithString @ http myurl.com script.php NSMutableURLRequest request NSMutableURLRequest requestWithURL.. setValue @ application xml charset utf 8 forHTTPHeaderField @ Content Type request setHTTPBody str dataUsingEncoding NSUTF8StringEncoding and on the server try the following PHP handle fopen php input rb http_raw_post_data '' while feof handle http_raw_post_data..

Reading PDF files as string through iPhone application

http://stackoverflow.com/questions/2362393/reading-pdf-files-as-string-through-iphone-application

MyDisplayPDFPage UIGraphicsGetCurrentContext initialPage NSBundle mainBundle pathForResource @ MobileHIG ofType @ pdf UTF8String imgV.image UIGraphicsGetImageFromCurrentImageContext imgV.image imgV.image rotate UIImageOrientationDownMirrored void touchesBegan.. 720 720 MyDisplayPDFPage UIGraphicsGetCurrentContext page NSBundle mainBundle pathForResource @ MobileHIG ofType @ pdf UTF8String CATransition transition CATransition animation transition.duration 0.75 transition.timingFunction CAMediaTimingFunction..

How to convert an NSString to hex values

http://stackoverflow.com/questions/3056757/how-to-convert-an-nsstring-to-hex-values

target type warning on the char declaration line but it works. NSString stringToHex NSString string char utf8 string UTF8String NSMutableString hex NSMutableString string while utf8 hex appendFormat @ 02X utf8 0x00FF return NSString stringWithFormat.. Java utf8 s.getBytes ENCODING_UTF8 new String decodedHexString ENCODING_UTF8 Objective C equivalents would be utf8 s UTF8String NSString initWithUTF8String decodedHexString To make an NSString with the hexadecimal representation of a character string.. new String decodedHexString ENCODING_UTF8 Objective C equivalents would be utf8 s UTF8String NSString initWithUTF8String decodedHexString To make an NSString with the hexadecimal representation of a character string NSMutableString hex NSMutableString..

Objective-c iPhone percent encode a string?

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

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 ' ' ..

iPhone Unzip code

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

@ sample.zip 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.. 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..

Using MD5 hash on a string in cocoa? [duplicate]

http://stackoverflow.com/questions/652300/using-md5-hash-on-a-string-in-cocoa

library #import CommonCrypto CommonDigest.h ... Function definition NSString md5 NSString str const char cStr str UTF8String unsigned char result CCMD5_DIGESTLENGTH CC_MD5 cStr strlen cStr result return NSString stringWithFormat @ 02X 02X 02X 02X..

iCloud basics and code sample [closed]

http://stackoverflow.com/questions/7795629/icloud-basics-and-code-sample

if contents length 0 self.documentText NSString alloc initWithBytes contents bytes length contents length encoding NSUTF8StringEncoding else self.documentText @ NSLog @ UIDocument Loaded the following text from the cloud @ self.documentText update.. UIDocument Will save the following text in the cloud @ self.documentText return NSData dataWithBytes self.documentText UTF8String length self.documentText length @end THE VIEWCONTROLLER ViewController.h iCloudText #import UIKit UIKit.h @class MyTextDocument..

URL encode an NSString

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

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 ' ' ..