macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

propertyListFromData:mutabilityOption:format:errorDescription:

データからプロパティリストをつくって返します
+(id)propertyListFromData:(NSData *)data
           mutabilityOption:(NSPropertyListMutabilityOptions)opt
           format:(NSPropertyListFormat *)format
           errorDescription:(NSString **)errorString

解説

データからプロパティリストをつくって返します。
【NSPropertyListFormat】
NSPropertyListOpenStepFormat
NSPropertyListXMLFormat_v1_0
NSPropertyListBinaryFormat_v1_0

【NSPropertyListMutabilityOptions】
NSPropertyListImmutable
NSPropertyListMutableContainers
NSPropertyListMutableContainersAndLeaves

返り値

( id )

オブジェクト

引数

( NSData * )data
( NSPropertyListMutabilityOptions )opt

ミュータブルオプション

( NSPropertyListFormat * )format

フォーマット

( NSString ** )errorString
Returns a p

エラー

クラス

NSPropertyListSerialization

Class Methods

使用可能

10.2

参照

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{

      NSString *error;
      NSData *serializationData;

    NSString *thePath = [[NSBundle mainBundle] pathForResource : @"theList" ofType:@"plist"];
    NSData *plistData = [ NSData dataWithContentsOfFile : thePath ] ;
    if ([NSPropertyListSerialization propertyList:plistData isValidForFormat:NSPropertyListXMLFormat_v1_0 ]){      
            serializationData = [NSPropertyListSerialization dataFromPropertyList: plistData 
          format: NSPropertyListXMLFormat_v1_0 
          errorDescription: &error];
          }
    id obj = [NSPropertyListSerialization propertyListFromData:serializationData
                                            mutabilityOption:NSPropertyListMutableContainers
                                            format: nil
                                            errorDescription:nil
                                            ];
    
    
          NSLog([ obj className]);
          
}

@end