Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

subclassing NSRRemoteObject decodeRemoteValue #19

Closed
hookercookerman opened this issue Jul 22, 2012 · 10 comments
Closed

subclassing NSRRemoteObject decodeRemoteValue #19

hookercookerman opened this issue Jul 22, 2012 · 10 comments

Comments

@hookercookerman
Copy link

why do I need to do this because I have a hash that I wish to decode

  def decodeRemoteValue(remoteObject, forRemoteKey:remoteKey, change:change)
    if remoteKey == "obj"
      self.obj = remoteObject
    else
      super(remoteObject, forRemoteKey:remoteKey, change:change)
    end
  end

Cannot define method decodeRemoteValue:forRemoteKey:change:' because no Objective-C stub was pre-compiled for typesv@:@@^c'. Make sure you properly link with the framework or library that defines this message.

@dingbat
Copy link
Owner

dingbat commented Jul 22, 2012

Hm, looks like this is indeed a bug in RubyMotion. Something to do with the 'changes' boolean pointer as a method argument. All the other overrides seem to work.

Thanks for posting, I'll send a bug report to Laurent soon.

Btw: There's no need to type out super(remoteObject, forRemoteKey:remoteKey, change:change) - Ruby lets you just put super :)

@dingbat
Copy link
Owner

dingbat commented Jul 22, 2012

Removing the 'changes' boolean anyway, which should make this work again.

The method'll just look like

def decodeRemoteValue(remoteObject, forRemoteKey:remoteKey)
  ...
end

@hookercookerman
Copy link
Author

off topic from here; but how do you decode a hash; as at present it returns nil;

what I mean is

[{"id":"500970c2b36c973013000006","obj":{"id":"50096e4ab36c973013000004","type":"Rejection","rejection_note":"cos it","name":"beans","chore_id":"50096e3fb36c973013000001","creator_id":"50082653b36c978ad300025b","recipient_id":"5008265ab36c97758300003c"}]

obj is not an association its just a hash that is then represented into json;

@dingbat
Copy link
Owner

dingbat commented Jul 23, 2012

No decoding necessary, this works out of the box.

Maybe you forgot to include it in the remoteProperties override?

@hookercookerman
Copy link
Author

class Activity < NSRRemoteObject
  attr_accessor :id, :obj, :created_at

  def remoteProperties
    super + ["id", "obj", "created_at"]
  end

end

is what I have; obj is decoded into nil cheers

@dingbat
Copy link
Owner

dingbat commented Jul 23, 2012

Strange. Could you post the server response when you fetch? Like this:

2012-07-23 07:06:04.708 NSRails-Ruby[51862:fb03] [NSRails][IN] <=== Code 200;  (
        {
        author = test;
        content = test;
        "created_at" = "2012-07-22T21:22:06Z";
        id = 21;
        responses =         (
        );
        "updated_at" = "2012-07-22T21:22:06Z";
    })

@dingbat
Copy link
Owner

dingbat commented Jul 23, 2012

And unrelated: it's not recommended to define an id property. Use the remoteID property that you get from subclassing NSRRemoteObject.

@dingbat
Copy link
Owner

dingbat commented Jul 24, 2012

Could you get it to work?

@hookercookerman
Copy link
Author

havent had a chance to check this over; but thanks for the heads up; will
let you know

cheers

On Tue, Jul 24, 2012 at 6:04 PM, dan hassin <
reply@reply.github.com

wrote:

Could you get it to work?


Reply to this email directly or view it on GitHub:
#19 (comment)

Richard Hooker

Dynamic50 Web Design and Development

"Web Development made simple"

Mob: +44 (0)7795063320
Skype: dynamic50.com
Email: richard.hooker@dynamic50.com
Web: http://www.dynamic50.com

Dynamic50 is part of the 50Group. The 50Group covers a wide range of
specialities including Web Design and Development, Search and Selection,
Web Production and Hosting.

*** DISCLAIMER ***
This message and any attachments are confidential, and may be protected by
legal privilege. If this has been sent to you in error please contact the
sender as soon as possible.

Dynamic50 Ltd is a limited company, registered in England and Wales,
registered number 06468278.

@dingbat
Copy link
Owner

dingbat commented Aug 14, 2012

Old - closing this. Everything described works fine on my machine.

@dingbat dingbat closed this as completed Aug 14, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants