Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

Commit

Permalink
Rollback accidental changes to ListManager
Browse files Browse the repository at this point in the history
These changes were part of the "Enable Async" issue (#4) and accidentally made their way into this commit when renaming the iOS source code folder.
  • Loading branch information
Emily Toop authored Nov 15, 2017
1 parent e8975b6 commit 62abac3
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions complex objects/ios/Toodle/Rust/List/ListManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,19 @@ import Foundation

class ListManager: RustObject {
let raw: OpaquePointer
fileprivate var categoriesCallback: (([Category]) -> ())?

required init(raw: OpaquePointer) {
self.raw = raw
}

func allCategories(closure: @escaping ([Category]) -> ()) {
self.categoriesCallback = closure
let cb: @convention(c) ((UnsafeMutablePointer<OpaquePointer?>?)) -> Void = { (categories) in
var allCategories: [Category] = []
for index in 0..<category_list_count(categories) {
let category = Category(raw: category_list_item_at(categories, index))
allCategories.append(category)
}
print("\(allCategories)")
closure(allCategories)
func allCategories() -> [Category] {
let categories = get_all_categories(self.raw)
var allCategories: [Category] = []
for index in 0..<category_list_count(categories) {
let category = Category(raw: category_list_item_at(categories, index))
allCategories.append(category)
}
get_all_categories(self.raw, cb)
return allCategories
}

func createCategory(withName name: String) -> Category {
Expand All @@ -37,14 +32,4 @@ class ListManager: RustObject {
func update(item: Item) throws {
category_manager_update_item(raw, item.raw)
}

func callback(categories: (UnsafeMutablePointer<OpaquePointer?>?)) {
var allCategories: [Category] = []
for index in 0..<category_list_count(categories) {
let category = Category(raw: category_list_item_at(categories, index))
allCategories.append(category)
}
print("\(allCategories)")
self.categoriesCallback?(allCategories)
}
}

0 comments on commit 62abac3

Please sign in to comment.