diff --git a/NativeScript/runtime/ArrayAdapter.mm b/NativeScript/runtime/ArrayAdapter.mm index aba9988f..546bea12 100644 --- a/NativeScript/runtime/ArrayAdapter.mm +++ b/NativeScript/runtime/ArrayAdapter.mm @@ -67,36 +67,6 @@ - (id)objectAtIndex:(NSUInteger)index { return value; } -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained _Nullable [_Nonnull])buffer count:(NSUInteger)len { - if (state->state == 0) { // uninitialized - state->state = 1; - void* selfPtr = (__bridge void*)self; - state->mutationsPtr = (unsigned long*)selfPtr; - state->extra[0] = 0; // current index - NSUInteger cnt = [self count]; - state->extra[1] = cnt; - } - - NSUInteger currentIndex = state->extra[0]; - unsigned long length = state->extra[1]; - NSUInteger count = 0; - state->itemsPtr = buffer; - - @autoreleasepool { - while (count < len && currentIndex < length) { - id obj = [self objectAtIndex:currentIndex]; - CFBridgingRetain(obj); - *buffer++ = obj; - currentIndex++; - count++; - } - } - - state->extra[0] = currentIndex; - - return count; -} - - (void)dealloc { self->cache_->Instances.erase(self); Local value = self->object_->Get(self->isolate_); @@ -106,6 +76,9 @@ - (void)dealloc { delete wrapper; } self->object_->Reset(); + self->isolate_ = nullptr; + self->cache_ = nullptr; + self->object_ = nullptr; [super dealloc]; } diff --git a/NativeScript/runtime/DictionaryAdapter.mm b/NativeScript/runtime/DictionaryAdapter.mm index 1e47e597..ba5e33d4 100644 --- a/NativeScript/runtime/DictionaryAdapter.mm +++ b/NativeScript/runtime/DictionaryAdapter.mm @@ -234,12 +234,12 @@ - (NSEnumerator*)keyEnumerator { Local obj = self->object_->Get(self->isolate_); if (obj->IsMap()) { - self->enumerator_ = [[DictionaryAdapterMapKeysEnumerator alloc] initWithMap:self->object_ isolate:self->isolate_ cache:self->cache_]; + self->enumerator_ = [[[DictionaryAdapterMapKeysEnumerator alloc] initWithMap:self->object_ isolate:self->isolate_ cache:self->cache_] autorelease]; return self->enumerator_; } - self->enumerator_ = [[DictionaryAdapterObjectKeysEnumerator alloc] initWithProperties:self->object_ isolate:self->isolate_ cache:self->cache_]; + self->enumerator_ = [[[DictionaryAdapterObjectKeysEnumerator alloc] initWithProperties:self->object_ isolate:self->isolate_ cache:self->cache_] autorelease]; return self->enumerator_; } @@ -261,6 +261,8 @@ - (void)dealloc { // CFAutorelease(self->enumerator_); self->enumerator_ = nullptr; } + self->cache_ = nullptr; + self->object_ = nullptr; [super dealloc]; } diff --git a/NativeScript/runtime/NSDataAdapter.mm b/NativeScript/runtime/NSDataAdapter.mm index d351d86b..5ea20948 100644 --- a/NativeScript/runtime/NSDataAdapter.mm +++ b/NativeScript/runtime/NSDataAdapter.mm @@ -66,6 +66,9 @@ - (void)dealloc { delete wrapper; } self->object_->Reset(); + self->isolate_ = nullptr; + self->cache_ = nullptr; + self->object_ = nullptr; [super dealloc]; }