2014-06-23 1 views
0

나는 잠시 후에 풀 수없는 문제에 관해 생각하고있다. 나는 아주 잘못된 것을해야 할 것입니다. 조회수는 UIView이고 UITableView입니다. 그것들은 NavigationController으로 내장되어 있습니다.NavigationController에서 int 전달하기

두 번째보기에서; TableView, NSInteger을 첫 번째보기 인 UIView로 다시 전달하고 싶습니다.

나는 https://stackoverflow.com/a/19343715/3355194의 솔루션을 사용했지만 나에게 도움이되지 못했습니다. 그것은 나에게 0 값을 다시 UIView에서 제공합니다. TableView에서 그것은 바로 값 numberOnSectionInTableView을 제공합니다. 다른 해결책을 시도했지만 동일한 결과가 나타납니다.

지금까지 내가 한 것. TableView.h에서

:

@protocol senddataProtocol <NSObject> 

-(void)sendBadgeIntBack:(int*)section; 

@property (nonatomic, assign) id delegate; 

TableView.m :

@synthesize delegate; 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    self.section = [self.tableView numberOfSections]; 
    section = [[[UIApplication sharedApplication] scheduledLocalNotifications] count]; 

    NSLog(@"Number of sections: %i", section-1); 

    return (int)[[[UIApplication sharedApplication] scheduledLocalNotifications] count]/2; 
} 

-(void)viewWillDisappear:(BOOL)animated 
{ 
    [delegate sendBadgeIntBack:&(section)]; 
} 

UIView.h :

@property (nonatomic) int section; 

UIView.m : 그것은 나에게 여기에 0 값을 제공합니다.

-(void)sendBadgeIntBack:(int*)section 
{ 
    NSLog(@"The numbers of sections in tableView are: %i", self.section); 
} 

당신이 해결책을 찾도록 도울 수 있기를 바랍니다. 미리 감사드립니다.

답변

1

당신은 프리미티브 값에 사용해야하는 값 (int) 대신에 (int *) 참조로 전달을 사용하고 있습니다. 단순화하기 위해 객체는 별, 정수, 부동 소수점, 구조체 등을 가져 오지 않습니다.

또한 문제가 여전히 지속되면 대리인을 제대로 설정하지 않았을 수 있으며 메서드에 중단 점을 넣고 제대로 호출되는지 확인할 수 있습니다. TableView.h에서

+0

Obj-c를 처음 사용하는 사람에게 감사의 말을 전합니다. 나는 그것이 어리석은 실수라는 것을 알았다. – SwingerDinger

+0

Np, 앞으로의 노력에 행운을 빕니다! – Adis

2

:

@protocol senddataProtocol <NSObject> 

-(void)sendBadgeIntBack:(int)section_selected; 

@property (nonatomic, assign) id delegate; 
@property (nonatomic) int section; 

TableView.m :

@synthesize delegate; 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    self.section = [self.tableView numberOfSections]; 
    section = [[[UIApplication sharedApplication] scheduledLocalNotifications] count]; 

    NSLog(@"Number of sections: %i", section-1); 

    return (int)[[[UIApplication sharedApplication] scheduledLocalNotifications] count]/2; 
} 

-(void)viewWillDisappear:(BOOL)animated 
{ 
    [delegate sendBadgeIntBack:section]; 
} 

UIView.h :

@property (nonatomic) int section; 

UIView.m : 그것은 여기 나에게 0 값을 제공합니다 .

-(void)sendBadgeIntBack:(int*)section_selected; 
{ 
self.section = section_selected; 
    NSLog(@"The numbers of sections in tableView are: %i", self.section); 
} 
관련 문제