- Joined
- May 27, 2012
- Messages
- 5
- Reaction score
- 0
- Points
- 1
I am using NSDictionay, but some questions really puzzled me.
Following is the related code
The main content of file used to to be parsed by NSDictionary is formed like following:
The function rangeInfoForPage will be called several time. After called some times, the program will crash. But if I only return nil in function rangeInfoForPage, then every thing is OK. And I debugged the program also, I found function rangeInfoForPage can return correct value for some first steps.
So, I am wondering whether I am not using NSDictionary correctly?
Could any one help me, I am studying iOS programming by myself, and I'm really blocked by this!
Following is the related code
Code:
@interface AttributedStringDoc : NSObject {
// ....... other properties
@private
// ..... other privates
NSDictionary *pageRangesInfo;
}
@end
@implementation AttributedStringDoc
// ....... other function's implementation
// this function is called by the init*** function
- (void)loadWithFileName {
// ....... other codes
pageRangesInfo = [[NSDictionary alloc] initWithContentsOfFile:filePath];
// .........other codes
}
-(NSDictionary *)rangeInfoForPage:(NSInteger)pageNumber {
return [pageRangesInfo objectForKey:[NSString stringWithFormat:@"%d", pageNumber]];
}
@end
The main content of file used to to be parsed by NSDictionary is formed like following:
Code:
<key>0</key>
<dict>
<key>ASD_RANGE_END_INDEX</key>
<integer>1256</integer>
<dict>
<key>1</key>
<dict>
<key>ASD_RANGE_END_INDEX</key>
<integer>5464</integer>
<dict>
The function rangeInfoForPage will be called several time. After called some times, the program will crash. But if I only return nil in function rangeInfoForPage, then every thing is OK. And I debugged the program also, I found function rangeInfoForPage can return correct value for some first steps.
So, I am wondering whether I am not using NSDictionary correctly?
Could any one help me, I am studying iOS programming by myself, and I'm really blocked by this!