summaryrefslogtreecommitdiff
path: root/bindings/objc/src/SwordBibleBook.mm
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/objc/src/SwordBibleBook.mm')
-rw-r--r--bindings/objc/src/SwordBibleBook.mm28
1 files changed, 15 insertions, 13 deletions
diff --git a/bindings/objc/src/SwordBibleBook.mm b/bindings/objc/src/SwordBibleBook.mm
index eeb956b..931963c 100644
--- a/bindings/objc/src/SwordBibleBook.mm
+++ b/bindings/objc/src/SwordBibleBook.mm
@@ -37,26 +37,30 @@
swBook = aBook;
sword::VerseKey vk = sword::VerseKey(aBook->getOSISName());
- [self setTestament:vk.Testament()];
- [self setNumberInTestament:vk.Book()];
+ [self setTestament:vk.getTestament()];
+ [self setNumberInTestament:vk.getBook()];
// get system localeMgr to be able to translate the english bookName
sword::LocaleMgr *lmgr = sword::LocaleMgr::getSystemLocaleMgr();
- self.localizedName = [NSString stringWithUTF8String:lmgr->translate(swBook->getLongName())];
+ const char *translated = lmgr->translate(swBook->getLongName());
+ self.localizedName = [NSString stringWithUTF8String:translated];
+
+ // in case we don't have ICU support this still works.
+ if(self.localizedName == nil) {
+ self.localizedName = [NSString stringWithCString:translated encoding:NSISOLatin1StringEncoding];
+ }
+ if(self.localizedName == nil) {
+ DLog(@"Unable to get this bookname: %s", translated);
+ }
}
return self;
}
-- (void)finalize {
- [super finalize];
-}
- (void)dealloc {
- [self setLocalizedName:nil];
[self setChapters:nil];
-
- [super dealloc];
+ [self setLocalizedName:nil];
}
- (NSString *)name {
@@ -76,8 +80,6 @@
}
- (void)setChapters:(NSArray *)anArray {
- [anArray retain];
- [chapters release];
chapters = anArray;
}
@@ -85,7 +87,7 @@
if(chapters == nil) {
NSMutableArray *temp = [NSMutableArray array];
for(int i = 0;i < swBook->getChapterMax();i++) {
- [temp addObject:[[[SwordBibleChapter alloc] initWithBook:self andChapter:i+1] autorelease]];
+ [temp addObject:[[SwordBibleChapter alloc] initWithBook:self andChapter:i+1]];
}
[self setChapters:[NSArray arrayWithArray:temp]];
}
@@ -106,7 +108,7 @@
/** we implement this for sorting */
- (NSComparisonResult)compare:(SwordBibleBook *)b {
- return [[NSNumber numberWithInt:number] compare:[NSNumber numberWithInt:[b number]]];
+ return [@(number) compare:@([b number])];
}
@end