objective c - Network handling in ios Programming -
i new ios programming.
now have model 'activity'. activity needs send , receive data server using afnetworking library.
there server manager dealing networking methods.
my idea create server manager instance when initialise each activity object, , receive data. therefore when need table of activities, have call instance repeatedly when create each activity
+ (servermanager*) instance { static servermanager *instance = nil; static dispatch_once_t oncetoken = 0; dispatch_once(&oncetoken, ^{ instance = [[servermanager alloc]init]; }); return instance; }
it makes sense valid or appropriate repeatedly create server manager instance?
or better call instance while loading ui , assigning every data in viewdidload?
thank you
there multiple ways want do, , depends on situation , amount of data want load. way is: rather extend activity class servermanager class, network methods available in servermanager automatically available activity class.
so way, each time create new activity class, has capability go out , data you.
again, subjective , way it.
hope helps.
Comments
Post a Comment