M
M
Max Onflic2014-06-26 14:08:24
Objective-C
Max Onflic, 2014-06-26 14:08:24

The UI on the device is not updated, everything works in the simulator. What can be wrong?

In the ViewDidLoad method, if you directly initialize on the UI, everything is fine, i.e. displays at startup both on the device and on the simulator. But, of course, the developed application has a network part. I used the log - the data is downloaded, I save it in UserDefaults, then I pull it from there, filter it - and display it on the UI. Something incomprehensible with requests, in the log it displays what many have - https://discussions.apple.com/message/26151528. Has anyone come across and resolved the issue? Device - iPhone 4s, iOS 7.1.x.
part of log:
Jun 26 01:06:32 iPhone-maxonflic kernel[0] : launchd[1374] Container: /private/var/mobile/Applications/77C28615-FB53-42E2-8923-40568E1D6E9D (sandbox)
Jun 26 01:06 :32 iPhone-maxonflic SpringBoard[34] : LICreateIconForImage passed NULL CGImageRef image
Jun 26 01:06:32 iPhone-maxonflic backboardd[28] : HID: The 'Passive' connection 'Timetable BSUIR' access to protected services is denied.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Max Onflic, 2014-06-26
@maxonflic

DetailViewController.m
-(IBAction)buttonAction:(id)sender {
    
    
    NSString *group=self.textFieldbegin.text;
    NSMutableString *harry=[NSMutableString stringWithString:@"http://www.bsuir.by/psched/rest/"];
    [harry appendString:group];
    NSString *string = harry;
    
    NSURL *url = [NSURL URLWithString:string];
    
    
    
    
  
    
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        
        
        MyParser *parser = [[MyParser alloc] initWithURL:url
                            ];
        
        
        [[NSUserDefaults standardUserDefaults] setObject:parser.items forKey:@"DKey"];
        
        
        
        
        
     });
    
    
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"MyNotification"
                                                        object:self];
    
    
    
    

    
    
    
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
    
    
   
    
    
        // записываем все сделанные изменения в хранилище
        [[NSUserDefaults standardUserDefaults] synchronize];
        
    
        
    
    
}


ParserDelegate.m 

@implementation MyParser

- (id)initWithURL:(NSURL*)url
{
    if (self = [super init]) {
        NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
        parser.delegate = self;
        _items = [NSMutableArray new];
        [parser parse];
    }
    return self;
}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
    if ([elementName isEqualToString:@"ROW"]) {
        if (attributeDict) {
            [_items addObject:attributeDict];
        }
    }
}







@end

ViewController.m - основной

в методе ViewDidLoad - [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector (maxkitten)
                                                 name:@"MyNotification"
                                               object:nil];

maxkitten - функция сортировки данных из userdefault, с вложенным в нее блоком ( единственное, что, как вариант, может портить картину - очень-очень много кода в блоке ( около 7 тысяч строк), н она симуляторе все отлично справляется)

Y
yakubov, 2014-06-26
@yakubov

Throw off the code as you download and save

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question