Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8804113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:31:13+00:00 2026-06-14T01:31:13+00:00

I have a RubyMotion class that reads from Twitter’s search API to create Tweet

  • 0

I have a RubyMotion class that reads from Twitter’s search API to create Tweet objects as below.

When I run it I get this error:

(main)> 2012-11-08 17:01:32.634 Hello[39940:c07] -[__NSCFString bytes]: unrecognized selector sent to instance 0xea1f800
2012-11-08 17:01:32.685 Hello[39940:c07] json.rb:20:in `parse:': NSInvalidArgumentException: -[__NSCFString bytes]: unrecognized selector sent to instance 0xea1f800 (RuntimeError)
    from tweets_controller.rb:11:in `create_tweets'
    from tweets_controller.rb:7:in `tweets'
    from twitter_view_controller.rb:21:in `tableView:numberOfRowsInSection:'
    from app_delegate.rb:10:in `application:didFinishLaunchingWithOptions:'
2012-11-08 17:01:32.686 Hello[39940:c07] *** Terminating app due to uncaught exception 'RuntimeError', reason: 'json.rb:20:in `parse:': NSInvalidArgumentException: -[__NSCFString bytes]: unrecognized selector sent to instance 0xea1f800 (RuntimeError)
    from tweets_controller.rb:11:in `create_tweets'
    from tweets_controller.rb:7:in `tweets'
    from twitter_view_controller.rb:21:in `tableView:numberOfRowsInSection:'
    from app_delegate.rb:10:in `application:didFinishLaunchingWithOptions:'

How should I parse the JSON?

class TweetsController
  def initialize
    @twitter_accounts = %w(dhh google)
  end

  def tweets
    @tweets ||= create_tweets
  end

  def create_tweets
    BW::JSON.parse(twitter_search_results)["results"].each do |result|
      @tweets << Tweet.new(result)
    end
    @tweets
  end

  def twitter_search_results
    query = @twitter_accounts.map{ |account| "from:#{account}" }.join(" OR ")
    url_string = "http://search.twitter.com/search.json?q=#{query}"
    url_string_escaped = url_string.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
    url = NSURL.URLWithString(url_string_escaped)
    request = NSURLRequest.requestWithURL(url)
    response = nil
    error = nil
    data = NSURLConnection.sendSynchronousRequest(request, returningResponse: response, error: error)
    ##raise "BOOM!" unless (data.length > 0 && error.nil?)
    json = NSString.alloc.initWithData(data, encoding: NSUTF8StringEncoding)
  end
end

class Tweet
  attr_reader :created_at, :from_user, :text
  def initialize(tweet_result)
    @created_at = tweet_result["created_at"]
    @from_user = tweet_result["from_user"]
    @text = tweet_result["text"]
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:31:14+00:00Added an answer on June 14, 2026 at 1:31 am

    Short answer: skip using Bubblewrap.

      def create_tweets
        json_string = twitter_search_results.dataUsingEncoding(NSUTF8StringEncoding)
        e = Pointer.new(:object)
        json_hash = NSJSONSerialization.JSONObjectWithData(json_string, options:0, error: e)
        json_hash["results"].each do |result|
          @tweets << Tweet.new(result)
        end
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a photography site that I want to prevent image copying from. How can
I have some data files in the resources/ folder for my Rubymotion project. How
have written this little class, which generates a UUID every time an object of
Have a look at one of my websites: moskah.com The problem is that it
Have a simple contact us XPage created. Have server side validation in place that
Have have this line of code in my form when I create a new
Have run into a bug with glibc's malloc(): http://sourceware.org/bugzilla/show_bug.cgi?id=4349 and am thinking a work
Have a script to add / remove options from a select field -- the
Most of this code is derived directly from the RubyMotion Locations sample. I defined
Have one Doubt In MVC Architecture we can able to pass data from Controller

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.