2014-01-14 106 views

回答

1

您可以輕鬆地添加CGPDFDocumentRef到您的NSArray或NSMutableArray裏,只要你施放他們適當類型添加/訪問時。

這裏是我測試的樣本代碼:

CFStringRef path; 
CFURLRef url; 
CGPDFDocumentRef document; 

NSString *nsstringPath = [[NSURL pathForDocumentsDirectory] stringByAppendingPathComponent:@"test.pdf"]; 

path = CFStringCreateWithCString (NULL, [nsstringPath cStringUsingEncoding:NSUTF8StringEncoding], kCFStringEncodingUTF8); 
url = CFURLCreateWithFileSystemPath (NULL, path, kCFURLPOSIXPathStyle, 0); 

CFRelease (path); 
document = CGPDFDocumentCreateWithURL (url); 
CFRelease(url); 
count = CGPDFDocumentGetNumberOfPages (document); 

NSMutableArray *testArray = [NSMutableArray array]; 
[test addObject:(__bridge id)(document)]; 

CGPDFDocumentRef testPdf = (__bridge CGPDFDocumentRef)([testArray objectAtIndex:0]); 

這裏是一個link蘋果文檔覆蓋免費橋接。它涵蓋了基礎框架,但應該給出一個想法。

希望這會有所幫助,乾杯!

0

它今天早些時候發佈了使用不同的對象,但我目前找不到它。

您可以創建一個NSValue對象添加到數組。不知道它是如何工作的,只是在這裏反芻信息:

[NSValue valueForBytes:(pointer) objCType:@encode(CGPDFDocumentRef)];