1、如何將 NSCFString 轉換 到的 NSString
方法如下:
1、創建字元串
1)NSSring *str = @」」;
2)NSString *str1 = [NSString new];
NSString *str2 = [[NSString alloc] initWithString:@」adf」] 等同於1)
4)NSString *str3 = [NSString stringWithFormat:@」name is %@」,@」小小」]
5)char *c = 「小小」;
NSString *str4 = [[NSString alloc] initWithCString:c encoding:nil]
2、獲取字元串(截取後創建了新的字元串,不改變原來的字元串)
NSString *str = @」www.itcast.cn」;
1)獲取字元串的長度
NSUInteger length = [str length];//str.length
2)根據索引獲得單個字元
unichar c = [str characterAtIndex:5];//索引從0開始
3)根據索引獲得字元串的一個子串
1> 截取字元從莫個位置開始到末尾
NSString *str1 = [str substingFormIndex:3];//從給定的索引(包含該索引位置)截取到字元串末尾
2> 截取字元從莫個位置開始到首位
NSString *str2 = [str substringToIndex:3];//截取字元串到給定索引的位置(不包含該索引的位置)
3> 截取字元從莫個位置開始到莫個位置結束
NSRang *rang = {1,2};//location(索引位置)、length(截取的長度)
NSString *str3 = [str substringWithRange:rang];//包含該索引的位置
2、cf里的ns是什麼意思?
應該是CS傳過來的
ns = nice = PL = n4 = 漂亮
3、iOS 開發中,CFURLRef 和 NSURL 到底什麼關系
首先CFURLRef和NSUR從屬不同框架,CFURLRef是Core Foundation的API,NSURL是Foundation的API,Core Foundation和Foundation中的有些數據類型只需要簡單的強內制類型轉換就容可以互換使用,這類類型我們叫他們為Toll-Free Bridged Types。 CFURLRef和NSUR就是其中的一對,Core Foundation的介面基本是C的介面,功能強大,但是使用起來沒有Foundation中提供的Objc的介面簡單好使,所以很多時候我們可以使用高層介面組織數據,然後將其傳給低層函數介面使用。
4、如何將cfdataref nsdata轉換為NSData
決方法;
/, height;/ Lock the base address of the pixel buffer
CVPixelBufferLockBaseAddress(imageBuffer;/ Create a bitmap graphics context with the sample buffer data
CGContextRef context = CGBitmapContextCreate(baseAddress, width; Works only if pixel format is kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
- (UIImage *):(CMSampleBufferRef)sampleBuffer{
/
// Create a Quartz image from the pixel data in the bitmap graphics context
CGImageRef quartzImage = CGBitmapContextCreateImage(context):quartzImage];
// Get a CMSampleBuffer;s Core Video image buffer for the media data
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
/ Free up the context and color space
CGContextRelease(context);
// Get the number of bytes per row for the plane pixel buffer
size_t bytesPerRow = (imageBuffer,0); Create a device-dependent gray color space
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
, colorSpace, 0);
size_t height = CVPixelBufferGetHeight(imageBuffer);
/:
pragma mark Convert SampleBuffer to UIImage
// Get the number of bytes per row for the plane pixel buffer
void *baseAddress = (imageBuffer;
/, kCGImageAlphaNone), 8,
bytesPerRow;/ Release the Quartz image
CGImageRelease(quartzImage), 0); Unlock the pixel buffer
(imageBuffer,0); Create an image object from the Quartz image
UIImage *image = [UIImage imageWithCGImage;
//
// Get the pixel buffer width and height
size_t width = CVPixelBufferGetWidth(imageBuffer);
//
CGColorSpaceRelease(colorSpace)
5、如何將 NSCFString 轉換 到的 NSString
char *c = "test";
CFStringRef str = CFStringCreateWithCString(NULL, c, kCFStringEncodingASCII);
NSString *test = [(NSString *)str substringToIndex:2];
NSLog(test);
可以的吧
6、CF里的NS是什麼意思啊****!!!!
Nice漂亮
大家喜歡叫奈思所以圖快打NS!望採納!
7、iOS 開發中,CFURLRef 和 NSURL 到底什麼關系
AFNetworking和ASIHTTPRequest都可以。來以下是源ASIHTTPRequest做的,你可以參考下://發送POST請求NSURL*nsUrl=[NSURLURLWithString:url];asiHttpRequest=[[ASIHTTPRequestalloc]initWithURL:nsUrl];[asiHttpRequestappendPostData:postData];[asiHttpRequestbuildPostBody];asiHttpRequest.timeOutSeconds=30;[];intstatusCode=[];NSLog(@"POSTresponsestatuscode:%d",statusCode);if(statusCode==200){}
8、如何將CFDataRef轉換為NSData
使用 [NSString stringWithFormat:NSData] (這里的NSData指的是需要轉換成NSString的NSData變數)即可。
如果po出的NSData是不可閱讀的亂碼,那一般都是有專編碼格式的,屬最常用的是NSUTF8StringEncoding,另外還有NSASCIIStringEncoding等,你可以在Apple文檔里找到編碼格式的那個枚舉類型,挨個嘗試。當然,如果事先知道得到的NSData的編碼類型就最好了。
9、如何將 NSCFString 轉換 到的 NSString
方法如下:
1、創建字元串
1)NSSring *str = @」」;
2)NSString *str1 = [NSString new];
NSString *str2 = [[NSString alloc] initWithString:@」adf」] 等同於1)
4)NSString *str3 = [NSString stringWithFormat:@」name is %@」,@」小小」]
5)char *c = 「小小」;
NSString *str4 = [[NSString alloc] initWithCString:c encoding:nil]
2、獲取字元串(截取後創建了新的字元串,不改變原來的字元串)
NSString *str = @」www.itcast.cn」;
1)獲取字元串的長度
NSUInteger length = [str length];//str.length
2)根據索引獲得單個字元
unichar c = [str characterAtIndex:5];//索引從0開始
3)根據索引獲得字元串的一個子串
1> 截取字元從莫個位置開始到末尾
NSString *str1 = [str substingFormIndex:3];//從給定的索引(包含該索引位置)截取到字元串末尾
2> 截取字元從莫個位置開始到首位
NSString *str2 = [str substringToIndex:3];//截取字元串到給定索引的位置(不包含該索引的位置)
3> 截取字元從莫個位置開始到莫個位置結束
NSRang *rang = {1,2};//location(索引位置)、length(截取的長度)
NSString *str3 = [str substringWithRange:rang];//包含該索引的位置
10、CF里的NS是什麼意思啊****!!!!
Nice漂亮 大家喜歡叫奈思所以圖快打NS!望採納!
希望採納