Can't populate UITableView with data from XML (Russian text does not appear in slog like it should)

52 Views Asked by At

i can't figure out why i can't see a proper text when parsing XML page. My code is working but, when i try to output in NSLog, i can see following:

{
        description = "\U0429\U0435\U043d\U043e\U043a \U0432 \U0434\U0430\U0440. \U041f\U0430\U043f\U0430 - \U043e\U0432\U0447\U0430\U0440 \U0412\U0415\U041e. \U041c\U0430\U043c\U0430 - \U043c\U0435\U0442\U0438\U0441 \U043b\U0430\U0431\U0440\U0430.";
    }

I already did parse XML from example populated with English letters, so why i can't see a Russian text here? Or maybe it is not about the text and i made some mistakes?

There is a code from my NSObject class i use to get data from:

@implementation requestManager


-(id)initWithDelegate:(id<requestDelegate>)delegateObject{

    self = [super init];
    if (self){

        self.delegate = delegateObject;
        self.contentData     = [NSMutableData data];
        self.listOfItems = [NSMutableArray array];
    }

    return self;
}

-(void)loadXmlData{

    NSURL *urlString = [NSURL URLWithString:@"http://*************url address**********"];
    NSURLRequest *req = [NSURLRequest requestWithURL:urlString];

    NSURLConnection *connection = [NSURLConnection connectionWithRequest:req delegate:self];
    [connection start];

}

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{


    [self.contentData appendData:data];
}

-(void)connectionDidFinishLoading:(NSURLConnection *)connection{

    NSXMLParser *parserObj = [[NSXMLParser alloc]initWithData:self.contentData];
    parserObj.delegate = self;
    [parserObj parse];
}



#pragma mark - XML PARSER DELEGATE METHODS

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{


    if ([elementName isEqualToString:@"description"]) isDescription = YES;
    if ([elementName isEqualToString:@"text"]) isText = YES;
    if ([elementName isEqualToString:@"name"]) isName = YES;


    if ([elementName isEqualToString:@"images"]){
        self.currentPosition = [NSMutableDictionary dictionary];
    }

}

-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{

    if ([elementName isEqualToString:@"description"]) isDescription = NO;
    if ([elementName isEqualToString:@"text"]) isText = NO;
    if ([elementName isEqualToString:@"name"]) isName = NO;

    if ([elementName isEqualToString:@"images"]){
        [self.listOfItems addObject:self.currentPosition];
    }
}

-(void)parserDidEndDocument:(NSXMLParser *)parser{

    NSLog(@"%@", self.listOfItems);
}

-(void)parser:(NSXMLParser*)parser foundCharacters:(NSString *)string{

    if (isDescription) [self.currentPosition setValue:string forKey:@"description"];
    if (isText) [self.currentPosition setValue:string forKey:@"text"];
    if (isName) [self.currentPosition setValue:string forKey:@"name"];


}
0

There are 0 best solutions below