aboutsummaryrefslogtreecommitdiff
path: root/iPhone
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2011-11-03 15:30:15 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2011-11-03 15:30:15 +0000
commitc8f808d09529cfcdccad070d5782820309e99770 (patch)
tree2c1f5062fd9c2de135a89c6be6259870261135d9 /iPhone
parent371dc04d5eee387439a6345e486eba9b8a1d0060 (diff)
[Author: thomasvl]
Fix memory model by making all the outlets assign not retain. The problem here is UIViewControllers will dump their view in low memory and then reload next time it is needed. So someone hangs on to the localizer for something else, it would keep the views also loaded, so this way the localizer won't keep any of the objects it points to alive via a retain. Note: the AppKit version sorta matches this since outlets aren't retained by default. Clear them in awakeFromNib since that is all they are needed for. R=dmaclach DELTA=19 (9 added, 0 deleted, 10 changed)
Diffstat (limited to 'iPhone')
-rw-r--r--iPhone/GTMUILocalizer.h6
-rw-r--r--iPhone/GTMUILocalizer.m17
2 files changed, 14 insertions, 9 deletions
diff --git a/iPhone/GTMUILocalizer.h b/iPhone/GTMUILocalizer.h
index 3d5552b..d34c4d0 100644
--- a/iPhone/GTMUILocalizer.h
+++ b/iPhone/GTMUILocalizer.h
@@ -65,9 +65,9 @@
id yetAnotherObjectToLocalize_;
NSBundle *bundle_;
}
-@property(retain) IBOutlet id owner;
-@property(retain) IBOutlet id otherObjectToLocalize;
-@property(retain) IBOutlet id yetAnotherObjectToLocalize;
+@property(nonatomic, assign) IBOutlet id owner;
+@property(nonatomic, assign) IBOutlet id otherObjectToLocalize;
+@property(nonatomic, assign) IBOutlet id yetAnotherObjectToLocalize;
- (id)initWithBundle:(NSBundle *)bundle;
diff --git a/iPhone/GTMUILocalizer.m b/iPhone/GTMUILocalizer.m
index 274eb04..efebc42 100644
--- a/iPhone/GTMUILocalizer.m
+++ b/iPhone/GTMUILocalizer.m
@@ -47,15 +47,20 @@
}
- (void)awakeFromNib {
- if (owner_) {
- NSBundle *newBundle = [[self class] bundleForOwner:owner_];
+ id owner = self.owner;
+ if (owner) {
+ NSBundle *newBundle = [[self class] bundleForOwner:owner];
bundle_ = [newBundle retain];
- [self localizeObject:owner_ recursively:YES];
- [self localizeObject:otherObjectToLocalize_ recursively:YES];
- [self localizeObject:yetAnotherObjectToLocalize_ recursively:YES];
+ [self localizeObject:self.owner recursively:YES];
+ [self localizeObject:self.otherObjectToLocalize recursively:YES];
+ [self localizeObject:self.yetAnotherObjectToLocalize recursively:YES];
} else {
- _GTMDevLog(@"Expected an owner_ set for %@", self);
+ _GTMDevLog(@"Expected an owner set for %@", self);
}
+ // Clear the outlets.
+ self.owner = nil;
+ self.otherObjectToLocalize = nil;
+ self.yetAnotherObjectToLocalize = nil;
}
+ (NSBundle *)bundleForOwner:(id)owner {