objective c - Syntax for passing “no options” to a parameter of type NSJSONWritingOptions -
in objective-c wrote code following:
nserror *error; nsdata *jsondata = [nsjsonserialization datawithjsonobject:somedictionary options:0 error:&error];
i trying same thing in swift. prompting xcode’s syntax checking wrote this:
var jsonerror: nserror let jsondata = nsjsonserialization.datawithjsonobject(somedictionary, options: nsjsonwritingoptions(), error: &jsonerror)
but gives me error: “could not find overload init
accepts supplied arguments.” think problem might nsjsonwritingoptions()
bit, , i’m guessing have swift syntax wrong. tried replacing nsjsonwritingoptions()
nsjsonwritingoptions(0)
, got same error; tried replacing nil
(as suggested this answer) got error “could not find overload __conversion
accepts supplied arguments.”
how can indicate want default json writing options, whatever might be?
the problem not nsjsonwritingoptions; type of error you're passing should nserror?
, not nserror
.
Comments
Post a Comment