ios - How to call and use a function contained in another class file? -


i'm having strange problem, need call void function called insertcommunication contained in class file named mbuser.m class, named prodottoviewcontroller.m. since function not in prodottoviewcontroller in mbuser.m need step import class properly, correct me if i'm wrong:

  1. import .h file of mbuser in prodottoviewcontroller.m, this:

    #import "prodottoviewcontroller.h" #import "mbuser.h"  @interface prodottoviewcontroller () {  } 
  2. create @class of mbuser so:

    @class mbuser; /* class declaration placed between #import(s) , @interface of prodottoviewcontroller.m*/ 
  3. create @property of mbuser in prodottoviewcontroller.m

    @property (strong, nonatomic) mbuser *userclass; 
  4. alloc , init-alize mbuser, in case in viewdidload function:

    - (void)viewdidload {     [super viewdidload];      _userclass = [[mbuser alloc] init]; } 

this code works, compiles , xcode gives me no error @ all, when try call function returns nil [even other objects inside mbuser] if mbuser correctly allocated can see here:

enter image description here

can please me?

edit: mbuser.m's init method

- (id)init {     self = [super init];      if (self) {         dispatch_once(&oncetoken, ^{             dictcache = [[nsmutabledictionary alloc] init];         });          logined = no;         allowlogin = yes;     }      return self; } 

  1. you must nil userclass somehow. find out going on add dealloc method (- (void)dealloc) mbuser class , put there breakpoint check when it's being deallocated.
  2. you don't need @class mbuser; in file in you've made import of class. @class forward declaring classes in header files.

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -