• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Deserializing binary file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Deserializing binary file


  • Subject: Deserializing binary file
  • From: david bonde <email@hidden>
  • Date: Thu, 11 Sep 2003 15:21:27 +0200

I have a program that needs to open a NSPropertyList which is stored as binary data. Following the example on <http://developer.apple.com/documentation/Cocoa/Conceptual/ PropertyLists/Tasks/SerializedPListsTask.html> I have come up with the following code:


NSString *error = nil;

[NSPropertyListSerialization
propertyListFromData:tbl
mutabilityOption:NSPropertyListMutableContainersAndLeaves
format:&NSPropertyListBinaryFormat_v1_0 // <--problematic line
errorDescription:&error];
}

However, compiling this code gives me the error message:

myApp.m:58: invalid lvalue in unary `&'

The weird thing is that PB highlights the errorDescription when I click on the error message

If I remove the "&":

format:NSPropertyListBinaryFormat_v1_0 // <--problematic line

I receive a fully understandable warning:

myApp.m:58: warning: passing arg 3 of `propertyListFromData:mutabilityOption:format:errorDescription:' makes pointer from integer without a cast


A few observations:

In the latter case the error message explicitly points out arg 3 as the culprit.

In the latter case the "&" used for arg 4 is accepted, but in the former case at least PB highlights arg 4 when the compiler complains about the "unary &"

The code at the example page I linked to looks like this (slightly edited):


NSString *error;
NSPropertyListFormat format;
id plist;


plist = [NSPropertyListSerialization
propertyListFromData:plistData
mutabilityOption:NSPropertyListImmutable
format:&format
errorDescription:&error];

They never set the format-variabled as far as I can see, but I guess it is supposed to be set somewhere outside this example. Ooh, and I take care of the return value from NSPropertyListSerialization but for caliry I removed that code here.

The API-documentation for propertyListFromData in NSPropertyListSerialization:

propertyListFromData:mutabilityOption:format:errorDescription:

+ (id) propertyListFromData: (NSData *) data mutabilityOption: (NSPropertyListMutabilityOptions) opt format: (NSPropertyListFormat *) format errorDescription: (NSString **) errorString
Returns a property list object corresponding to the representation in data of format format , or nil if data does not represent a property list in a supported format. The mutability option opt determines whether the property list's containers and/or leaves are mutable. If the property list is valid, the format is returned through the pointer format . Possible values for opt and format are described in "Constants" .

See Also: + dataFromPropertyList:format:errorDescription:





I have no clue. Suggestions?

Thanks
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • RE: Deserializing binary file
      • From: "Jonathan E. Jackel" <email@hidden>
  • Prev by Date: Re: OT: Documentation for writing iPhoto Plug-ins
  • Next by Date: Re: NSURL
  • Previous by thread: Re: Accessing a customer Objective C classes from Java
  • Next by thread: RE: Deserializing binary file
  • Index(es):
    • Date
    • Thread