iphone - Simplest way to encapsulate multiple method arguments? -



iphone - Simplest way to encapsulate multiple method arguments? -

+ (planet *)createplanetincontext:(nsmanagedobjectcontext *)context withname:(nsstring *)name type:(nsstring *)type group:(nsstring *)group anddiameter:(nsnumber *)diameter {

if wanted encapsulate arguments "name", "type", "group" , "diameter" single entity passing above method best type utilize encapsulation? above method quick illustration argue fine presented, if there many more arguments needed passed. need bundle info before calling method solution needs quick , simple setup.

+ (planet *)createplanetwithdata:(data *)data incontext:(nsmanagedobjectcontext *)context {

or more inline objective-c practices (more readable) individually list arguments?

i'd want individually list arguments, clarity. sample method you've posted above isn't terribly long, in context of objective-c.

it's readability , documentation. when list arguments it's clear developers coming project what's beingness passed in where, , kinds of objects floating around. automatic documentation generation (eg, doxygen) works off lists of arguments particularly well.

but there point @ which, say, becomes little unwieldy. 20 parameters pass in , method calls going very, long! there other options available - easiest 1 utilize nsdictionary or similar, used in ios ferry bits of info around (particularly notifications, have userinfo dictionary).

iphone objective-c xcode cocoa-touch

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -