2014-02-14 6 views
0

Мой метод ParseXML считывает значение NSNumber, которое можно увеличить одним нажатием кнопки.Мой взгляд не обновляется

метод

Моего ParseXML имеет 240 объектов, каждый из 8 имеет идентификатор от 1 до 30.

Идея заключается в том, что если я увеличиваю NSNumber от 1 до 2, освежает мой взгляд и захватывают 8 объектов, которые соответствуют ID и отображает его на мой взгляд.

Это точно, что не делается.

.h 

@interface FixturesController : UITableViewController 
{ 
    NSMutableData *_responseDataFixtures; 
    int goUp; 
    NSNumber *test; 
} 

@property (nonatomic, retain) NSArray *tableDataFixtures; 
@property (nonatomic, strong) NSMutableArray *roundParser; 
@property (nonatomic, strong) NSString *seasonRoundString; 
@property (nonatomic, strong) NSNumber *seasonRoundNumber; 

- (IBAction)goUpByOne:(UIButton *)sender; 

-(void) parseXMLFixtures:(NSNumber *) giveME; 



@end 


.m 


- (void) viewWillAppear:(BOOL)animated{ 
    [super viewWillAppear:animated]; 
    [self parseXMLFixtures:@2]; 
} 


- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    goUp = 1; 
    test = [NSNumber numberWithInt:goUp]; 

} 

// this allows me to increment the count of NSNumber. 
- (IBAction)goUpByOne:(UIButton *)sender { 

    goUp++; 

    test = [NSNumber numberWithInt:goUp]; 

    goUp = [test intValue]; 

} 


-(void) parseXMLFixtures:(NSNumber *) giveME 
{ 

    giveME = test; 

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"There's no going back"]]; 

    NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; 

    NSString *xmlString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]; 

    NSDictionary *xml = [NSDictionary dictionaryWithXMLString:xmlString]; 

    NSMutableArray *items = [xml objectForKey:@"Match"]; 

    NSMutableArray *newFixtureObjectArray = [[NSMutableArray alloc] init]; 

    NSNull *nullValue = [NSNull null]; 

    [newFixtureObjectArray insertObject:nullValue atIndex:0]; 
    [newFixtureObjectArray insertObject:nullValue atIndex:1]; 

    for (NSDictionary *dict in items) { 
     FixturesObject *myFixtures = [FixturesObject fixtureFromXMLDictionary:dict]; 
     [newFixtureObjectArray addObject:myFixtures]; 
    } 

    /////// 

    _seasonRoundString = [NSString stringWithFormat:@"%d", [giveME intValue]]; 
    _roundParser = [[NSMutableArray alloc]init]; 

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"round == %@", _seasonRoundString]; 
    NSArray *filteredArray = [newFixtureObjectArray filteredArrayUsingPredicate:predicate]; 
    _roundParser = [NSMutableArray arrayWithArray:filteredArray]; 
    [_roundParser insertObject:nullValue atIndex:0]; 

    NSLog(@" Objects of Fixtures in my array %@", _roundParser); 

    ///// 

    [self setTableDataFixtures:_roundParser]; 
} 

Любые предложения? Спасибо. Мне действительно нужно это работать, чтобы я мог спать

+0

Пробовали ли вы 'viewDidAppear' вместо' viewWillAppear'? – Lexicon

ответ

0

Вы уже использовали методы UITableViewDelegate, UITableViewDataSource?

методы являются:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ } 

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { } 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{} 

Вы можете следить за этим tutorial

Смежные вопросы