Skip to content

Instantly share code, notes, and snippets.

@carlwoodward
Last active August 29, 2015 14:08
Show Gist options
  • Save carlwoodward/d60b2ec6f0389f0bae4a to your computer and use it in GitHub Desktop.
Save carlwoodward/d60b2ec6f0389f0bae4a to your computer and use it in GitHub Desktop.

When using ProMotion and motion-kit I get this error:

2014-10-27 20:57:15.880 revisit_motion[40985:1651453] comment_cell.rb:25:in `setup:': Invalid Reference - probably recycled (WeakRef::RefError)
	from table.rb:121:in `create_table_cell:'
	from table.rb:110:in `table_view_cell:'
	from table.rb:153:in `tableView:cellForRowAtIndexPath:'
2014-10-27 20:57:15.894 revisit_motion[40985:1651453] *** Terminating app due to uncaught exception 'WeakRef::RefError', reason: 'comment_cell.rb:25:in `setup:': Invalid Reference - probably recycled (WeakRef::RefError)
	from table.rb:121:in `create_table_cell:'
	from table.rb:110:in `table_view_cell:'
	from table.rb:153:in `tableView:cellForRowAtIndexPath:'

comment_cell.rb looks like this:

class CommentCell < PM::TableViewCell
  include PM::TableViewCellModule

  def initWithStyle(data_cell, reuseIdentifier: identifier)
    super
    self
  end

  def setup(data_cell, table_screen)
    super
    @table_screen = table_screen
    @attrs = data_cell[:style]

    self.selectionStyle = UITableViewCellSelectionStyleNone
    @layout ||= begin
      layout = CommentCellLayout.new(root: self)
      layout.build
      layout.avatar.sizeToFit
      layout.body.sizeToFit
      layout.on :comments do
        perform_comments
      end
      layout
    end
    @layout.username.text = @attrs[:username]

    self
  end
  
  ...
  
end

And comment_cell_layout.rb is:

class CommentCellLayout < MotionKit::Layout
  view :username
  view :avatar
  view :body
end

Changing comment_cell_layout.rb to:

class CommentCellLayout < MotionKit::Layout
  view :username
  view :avatar
  view :body

  def initialize(args={})
    super
    @preset_root = WeakRef.new args[:root]
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment