Created
June 26, 2013 04:00
-
-
Save mrcave/5864677 to your computer and use it in GitHub Desktop.
ProMotion MotionModel incompatibility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppDelegate < PM::Delegate | |
attr_reader :window | |
def on_load(app, options) | |
open ListEntriesScreen.new(nav_bar: true) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Entry | |
include MotionModel::Model | |
include MotionModel::ArrayModelAdapter | |
columns :entry_date => :date, | |
:details => :text, | |
:created_at => :date, | |
:updated_at => :date | |
def after_save(sender) | |
Entry.serialize_to_file('entries.dat') | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2013-06-25 22:51:44.769 BestFed[82629:c07] model.rb:802:in `method_missing:': undefined method `[]' for Entry#1:0x9ca8e40:Entry (NoMethodError) | |
from _table.rb:106:in `tableView:titleForHeaderInSection:' | |
from _table.rb:43:in `update_table_view_data:' | |
from _table_screen_module.rb:9:in `update_table_data' | |
from list_entries_screen.rb:17:in `block in on_load' | |
from model.rb:320:in `issue_notification:' | |
from model.rb:514:in `block in save_without_transaction:' | |
from model.rb:541:in `call_hooks:' | |
from model.rb:501:in `save_without_transaction:' | |
from model.rb:494:in `save:' | |
from model.rb:212:in `create:' | |
from list_entries_screen.rb:51:in `new_entry' | |
2013-06-25 22:51:44.771 BestFed[82629:c07] *** Terminating app due to uncaught exception 'NoMethodError', reason: 'model.rb:802:in `method_missing:': undefined method `[]' for Entry#1:0x9ca8e40:Entry (NoMethodError) | |
from _table.rb:106:in `tableView:titleForHeaderInSection:' | |
from _table.rb:43:in `update_table_view_data:' | |
from _table_screen_module.rb:9:in `update_table_data' | |
from list_entries_screen.rb:17:in `block in on_load' | |
from model.rb:320:in `issue_notification:' | |
from model.rb:514:in `block in save_without_transaction:' | |
from model.rb:541:in `call_hooks:' | |
from model.rb:501:in `save_without_transaction:' | |
from model.rb:494:in `save:' | |
from model.rb:212:in `create:' | |
from list_entries_screen.rb:51:in `new_entry' | |
' | |
*** First throw call stack: | |
(0x1e28012 0x977e7e 0x43cbdd 0x4042 0x30a5) | |
libc++abi.dylib: terminate called throwing an exception | |
*** simulator session ended with error: Error Domain=DTiPhoneSimulatorErrorDomain Code=1 "The simulated application quit." UserInfo=0x100113380 {NSLocalizedDescription=The simulated application quit., DTiPhoneSimulatorUnderlyingErrorCodeKey=-1} | |
rake aborted! | |
Command failed with status (1): [DYLD_FRAMEWORK_PATH="/Applications/Xcode.a...] | |
/Library/RubyMotion/lib/motion/project/template/ios.rb:112:in `block in <top (required)>' | |
Tasks: TOP => default => simulator | |
(See full trace by running task with --trace) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EntriesListScreen < ProMotion::TableScreen | |
title "Entries" | |
def on_load | |
Entry.deserialize_from_file('entries.dat') | |
@table_data = Entry.all | |
@entry_model_change_observer = App.notification_center.observe MotionModelDataDidChangeNotification do |notification| | |
if notification.object.is_a?(Entry) | |
update_table_data | |
end | |
end | |
#adds top right "new" button | |
right_button = UIBarButtonItem.alloc.initWithBarButtonSystemItem(UIBarButtonSystemItemAdd, target:self, action:"new_entry") | |
self.navigationItem.rightBarButtonItem = right_button | |
end | |
def will_appear | |
@view_setup ||= set_up_view | |
end | |
def table_data | |
@table_data = Entry.all | |
end | |
def new_entry | |
#demo - just create new entry in tableview | |
Entry.create :details => "New entry" | |
end | |
def tapped_item(item) | |
open EntryDetailScreen.new(item: item) | |
end | |
def set_up_view | |
set_attributes self.view, { | |
frame: [[0,0],[320,416]] | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment