Невозможно получить какие-либо свойства моего другого класса [цель с] - PullRequest
0 голосов
/ 23 октября 2019

У меня есть два класса, а именно classA и classB, при попытке доступа к свойствам classA из экземпляра значения всегда равны нулю в classB.

Мой код выглядит так

classA.h

@interface classA:UITableViewController
@property (strong,nonatomic) IBoutlet UITableView *messageView;
+(classA *) controlFunction;
@property (nonatomic,readwrite) NSInteger count;
@end

classA.m

@interface classA(){
  NSArray *messages;
}
@end

@implementation classA
@synthesize count;
@synthesize messageView;
+(classA*) controlFunction{
    classA *control = nil;
    if(control){
       control=[[classA alloc]init];
    }
  return control;
}
-(id)init{
    if(!(self=[super init])) return nil;
   return self;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  self.count = messages.count;
  return self.count; //when I debug here I get 3 rows of my view but not in my other class
}
@end

classB.h

@interface classB:UIViewController
//some IBOutlets of this class are present here
@end

classB.m


@implementation classB{
//here I have code related to  UIKeyboardhiddenNotification notification and UIkeyboardshowNotification code the place where I want to use those properties is in a function when keyboard is shown


-(void) valueChanged:(NSNotification*) notification{
....
...
..
[UIView anuimatewithDuration:0 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
[self.view layoutIfNeeded];
} completion:^(BOOL finished){
//code for completion 
//so this the place where I want those properties, just to make that table view scroll to the last index when keyboard pops up
//currently my code is 
   NSInteger num;
   num = [[classA control] count-1]; //here I'm getting nil where I have 4 rows in the table view
   NSIndexPath *indexPath=[NSIndexPath indexPathForRow:num inSection:0];
   [[[classA control] messageView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
   }];
  }
}

Моя цель простосделайте прокрутку моего табличного представления до конца представления так, чтобы последний ряд был виден, когда пользователь фактически использует клавиатуру для ввода своего текста. Чтобы достичь этого, мне нужно получить свойство в моем классе B, в настоящее время я не могу делать то же самое, все равно нулю.

PS: Поскольку я новичок в объективе-C, я старался изо всех сил доздесь и не смог придумать решение, я пытался объяснить все возможное, я надеюсь, что любой из вас может помочь мне.

TIA

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...