2011-02-05 23 views
0

我正在編寫一個iPad應用程序,該應用程序將在我的MacBook Pro上使用多個文本文件作爲將在iPad上顯示的UITableViews的數據源。將文本文件從MacBook Pro傳輸到iPad

幾個問題:

  1. 我明白,爲了讓我的應用程序來從我的MacBook Pro在USB/iPad的接口文件,我的應用程序必須支持文件共享。我該如何做到這一點?

  2. 由於蘋果公司將iPad製作成電器,我無法看到它的文件系統。那麼如何聲明路徑來存儲提取的文件呢? iPad是多用戶主目錄的多用戶計算機嗎?

  3. 我可以寫我的應用程序與配件連接器中的SD卡連接以便從該卡獲取文本文件嗎?我應該用什麼課程來做到這一點?

回答

0

  1. [http://developer.apple.com/library/ios/#documentation/General/Reference /InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW1] [1] 將UIFileSharingEnabled項添加到Info.plist文件中。要查看這些文件,請打開iTunes,查看左側面板,單擊iPad,查看主內容窗格上方的工具欄,單擊「應用程序」,SCROLL DOWN,然後您會看到可以放置文件和導出文件(但你不能拖動它們,這很煩人)。我實際上也被困在這
  2. 你使文件共享文件可見的方式是將它們寫入一個神奇的目錄,該目錄由以下代碼獲得:
     
    
    
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
        NSString* documentDirPath = [paths objectAtIndex:0]; 
     
    
    以下是我在完整使用的例程:
    
    NSString* FileUtils_newUserVisibleFilePath(NSString* toFile) { 
         NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 
         NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
         NSString* documentDirPath = [paths objectAtIndex:0]; 
         NSString* filePath; 
         if ([documentDirPath characterAtIndex:[documentDirPath length]-1] != '/') { 
           filePath = [[NSString alloc] initWithFormat:@"%@/%@",documentDirPath,toFile]; 
         } else { 
           filePath = [[NSString alloc] initWithFormat:@"%@%@",documentDirPath,toFile]; 
         } 
         [pool release]; 
         return filePath; 
    } 
     
    
  3. 我不知道。但是,我也知道很多iPad用戶不使用SD卡,所以我認爲這是少數功能

一些開發人員最終做的是在iPad上提供HTTP服務器。 [1]:http://developer.apple.com/library/ios/#documentation/General/Reference /InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW1

相關問題