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

Commit

Permalink
Rename source code folder to Toodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Emily Toop committed Nov 15, 2017
1 parent 1e0d0c8 commit e8975b6
Show file tree
Hide file tree
Showing 20 changed files with 25 additions and 10 deletions.
6 changes: 3 additions & 3 deletions complex objects/ios/Toodle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
7B9F01031F794DB1000407E5 = {
isa = PBXGroup;
children = (
7B9F010E1F794DB2000407E5 /* ComplexRust */,
7B9F010E1F794DB2000407E5 /* Toodle */,
7B9F010D1F794DB2000407E5 /* Products */,
7B9F01261F794F3B000407E5 /* Frameworks */,
);
Expand All @@ -123,7 +123,7 @@
name = Products;
sourceTree = "<group>";
};
7B9F010E1F794DB2000407E5 /* ComplexRust */ = {
7B9F010E1F794DB2000407E5 /* Toodle */ = {
isa = PBXGroup;
children = (
7B2BA8941F963C5C0093D191 /* Rust */,
Expand All @@ -135,7 +135,7 @@
7B9F01181F794DB2000407E5 /* LaunchScreen.storyboard */,
7B9F01341F7D1634000407E5 /* NSLayoutConstraint+Utils.swift */,
);
path = ComplexRust;
path = Toodle;
sourceTree = "<group>";
};
7B9F01261F794F3B000407E5 /* Frameworks */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@ import Foundation

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

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

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)
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)
}
return allCategories
get_all_categories(self.raw, cb)
}

func createCategory(withName name: String) -> Category {
Expand All @@ -32,4 +37,14 @@ 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 e8975b6

Please sign in to comment.