iOS owner pattern changed to use WeakRef in order to prevent memory leaks.

Optimized list-view-tests.
Added time per test.
This commit is contained in:
hshristov
2015-10-22 10:26:59 +03:00
parent 9c0ac9e471
commit f72d79e65a
22 changed files with 863 additions and 791 deletions

View File

@@ -13,19 +13,20 @@ function onCheckedPropertyChanged(data: dependencyObservable.PropertyChangeData)
global.moduleMerge(common, exports);
class SwitchChangeHandlerImpl extends NSObject {
static new(): SwitchChangeHandlerImpl {
return <SwitchChangeHandlerImpl>super.new();
}
private _owner: Switch;
private _owner: WeakRef<Switch>;
public initWithOwner(owner: Switch): SwitchChangeHandlerImpl {
this._owner = owner;
return this;
public static initWithOwner(owner: WeakRef<Switch>): SwitchChangeHandlerImpl {
let handler = <SwitchChangeHandlerImpl>SwitchChangeHandlerImpl.new();
handler._owner = owner;
return handler;
}
public valueChanged(sender: UISwitch) {
this._owner._onPropertyChangedFromNative(common.Switch.checkedProperty, sender.on);
let owner = this._owner.get();
if (owner) {
owner._onPropertyChangedFromNative(common.Switch.checkedProperty, sender.on);
}
}
public static ObjCExposedMethods = {
@@ -41,7 +42,7 @@ export class Switch extends common.Switch {
super();
this._ios = new UISwitch();
this._handler = SwitchChangeHandlerImpl.new().initWithOwner(this);
this._handler = SwitchChangeHandlerImpl.initWithOwner(new WeakRef(this));
this._ios.addTargetActionForControlEvents(this._handler, "valueChanged", UIControlEvents.UIControlEventValueChanged);
}