iphone - Initialize Properties -


so have class need initialize properties once after first initialization. these properties need not reinitialized whole run of program. how do in ios 7 sdk? tried use initwithnibname, doesn't run, @ all. same init. method should use?

here's code

psacurrentgame.h:   #import <uikit/uikit.h> #import "phase10scorer.h"  @interface psacurrentgame : uiviewcontroller  @property (strong, nonatomic) nsarray *playernamesarray; @property (nonatomic) bool movenums; @property (strong, nonatomic) phase10scorer *scorer; @property (strong, nonatomic) nsmutablearray *r1scores; @property (strong, nonatomic) nsmutablearray *r1phases; @property (strong, nonatomic) nsmutablearray *r2scores; @property (strong, nonatomic) nsmutablearray *r2phases; @property (strong, nonatomic) nsmutablearray *r3scores; @property (strong, nonatomic) nsmutablearray *r3phases; @property (strong, nonatomic) nsmutablearray *toscores; @property (strong, nonatomic) nsmutablearray *tophases;  @end 

psacurrentgame.m:

#import "psacurrentgame.h" #import "phase10scorer.h"  @interface psacurrentgame () @property (strong, nonatomic) iboutletcollection(uilabel) nsarray *round1scores; @property (strong, nonatomic) iboutletcollection(uilabel) nsarray *round1phases; @property (strong, nonatomic) iboutletcollection(uilabel) nsarray *round2scores; @property (strong, nonatomic) iboutletcollection(uilabel) nsarray *round2phases; @property (strong, nonatomic) iboutletcollection(uilabel) nsarray *round3scores; @property (strong, nonatomic) iboutletcollection(uilabel) nsarray *round3phases; @property (strong, nonatomic) iboutletcollection(uilabel) nsarray *totalscores; @property (strong, nonatomic) iboutletcollection(uilabel) nsarray *totalphases;   @property (strong, nonatomic) iboutletcollection(uilabel) nsarray *playernames; @property (strong, nonatomic) iboutletcollection(uilabel) nsarray *roundlabelssecondset;   @end  @implementation psacurrentgame  - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil {     self = [super initwithnibname:nibnameornil bundle:nibbundleornil];     if (self) {         // custom initialization         self.scorer = [[phase10scorer alloc] init];         self.r1scores = [[nsmutablearray alloc] initwithobjects:[nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], nil];          self.r1phases = [[nsmutablearray alloc] initwithobjects:[nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], nil];         self.r2scores = [[nsmutablearray alloc] initwithobjects:[nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], nil];         self.r2phases = [[nsmutablearray alloc] initwithobjects:[nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], nil];         self.r3scores = [[nsmutablearray alloc] initwithobjects:[nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], nil];         self.r3phases = [[nsmutablearray alloc] initwithobjects:[nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], nil];         self.toscores = [[nsmutablearray alloc] initwithobjects:[nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], nil];         self.tophases = [[nsmutablearray alloc] initwithobjects:[nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], [nsnumber numberwithint:0], nil];         self.movenums = true;     }     return self; }  - (void)viewdidload {     [super viewdidload];     // additional setup after loading view.     int j = 0;     (uilabel *playerlabel in self.playernames) {         playerlabel.text = self.playernamesarray[j];         j++;     }      if (self.movenums) {       (int = 0; < 5; i++) {         self.r3scores[i] = self.r2scores[i];         self.r2scores[i] = self.r1scores[i];         self.r1scores[i] = self.toscores[i];          self.r3phases[i] = self.r2phases[i];         self.r2phases[i] = self.r1phases[i];         self.r1phases[i] = self.tophases[i];          self.toscores[i] = [nsnumber numberwithint:([self.scorer getscores:(i + 1)])];         self.tophases[i] = [nsnumber numberwithint:([self.scorer getphases:(i + 1)])];     }     }     int = 0;     (uilabel *tf in self.totalscores) {         uilabel *pname = self.playernames[i];         if ([pname.text isequaltostring:@""]) {             pname.hidden = true;             tf.hidden = true;             i++;             continue;         }         tf.text = self.toscores[i];         i++;     }      = 0;      (uilabel *tf in self.totalphases) {         uilabel *pname = self.playernames[i];         if ([pname.text isequaltostring:@""]) {             tf.hidden = true;             i++;             continue;         }         tf.text = self.tophases[i];         i++;     }          = 0;      (uilabel *tf in self.round1scores) {         uilabel *pname = self.playernames[i];         if ([pname.text isequaltostring:@""]) {             tf.hidden = true;             i++;             continue;         }         tf.text = self.r1scores[i];         i++;     }          = 0;      (uilabel *tf in self.round1phases) {         uilabel *pname = self.playernames[i];         if ([pname.text isequaltostring:@""]) {             tf.hidden = true;             i++;             continue;         }         tf.text = self.r1phases[i];         i++;     }          = 0;      (uilabel *tf in self.round2scores) {         uilabel *pname = self.playernames[i];         if ([pname.text isequaltostring:@""]) {             tf.hidden = true;             i++;             continue;         }         tf.text = self.r2scores[i];         i++;     }          = 0;      (uilabel *tf in self.round2phases) {         uilabel *pname = self.playernames[i];         if ([pname.text isequaltostring:@""]) {             tf.hidden = true;             i++;             continue;         }         tf.text = self.r2phases[i];         i++;     }          = 0;      (uilabel *tf in self.round3scores) {         uilabel *pname = self.playernames[i];         if ([pname.text isequaltostring:@""]) {             tf.hidden = true;             i++;             continue;         }         tf.text = self.r1scores[i];         i++;     }          = 0;      (uilabel *tf in self.round3phases) {         uilabel *pname = self.playernames[i];         if ([pname.text isequaltostring:@""]) {             tf.hidden = true;             i++;             continue;         }         tf.text = self.r1phases[i];         i++;     }  }  - (void)didreceivememorywarning {     [super didreceivememorywarning];     // dispose of resources can recreated. }  @end 

you should use awakefromnib instead.

- (void) awakefromnib {      //custom initialization } 

initwithnibname not called when instantiate view controller xib or storyboard.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -