Trying to get simple example going with no luck.

58 views
Skip to first unread message

aidan james

unread,
Feb 3, 2011, 2:30:20 AM2/3/11
to ObjectiveResource
Hello,
I need some help getting a simple Test Program that pull a few rows of
data from a running rails app Unfortunately, I cannot seem to get
past the tutorial. The issues I am having appear in searches but
nothing I've tried or found made any difference. I've tried as many of
the similar issues suggestions but it still does not work and I have
no idea why? I tried both the XML and JSon choices. Neither works. The
error messages below.

Can anyone help identify what may be going wrong here??? Thank you.

My client-side model (I've tried to change the type of neighborhoodId
but it did no seem to matter)

@interface Neighborhood : NSObject {
NSString *name;
NSString *description;
NSString *smallImageURL;
NSString *largeImageURL;
NSDate *updatedAt;
NSDate *createdAt;
}

Rails Model:
# == Schema Information
# Schema version: 20110202215058
#
# Table name: neighborhoods
#
# id :integer not null, primary key
# name :string(255)
# description :string(255)
# small_image_url :string(255)
# large_image_url :string(255)
# created_at :datetime
# updated_at :datetime
#

There are two error cases that I am receiving both of which prevent
any data from being seen.

XML - In this case it appears that the data was received. However it
crashes and I don't know why? I have spend a few hours trying various
patches and suggestions but nothing is working.


//loading data in viewController
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];

[ObjectiveResourceConfig setSite:@"http://localhost:3000/"];

//Set the username and password to be used for the remote site
[ObjectiveResourceConfig setUser:@""];
[ObjectiveResourceConfig setPassword:@""];

//Set ObjectiveResource to use either XML or JSON
//[ObjectiveResourceConfig setResponseType:XmlResponse];//the default
[ObjectiveResourceConfig setResponseType:JSONResponse];

neighborhoods = [Neighborhood findAllRemote];
NSLog(@"count = %d", [neighborhoods count]);

}


XML Errors:
2011-02-03 02:10:17.080 My-RailsToIPhoneTest[814:207] -[Neighborhood
isEqualToString:]: unrecognized selector sent to instance 0x4e35aa0
2011-02-03 02:10:17.082 My-RailsToIPhoneTest[814:207] *** Terminating
app due to uncaught exception 'NSInvalidArgumentException', reason: '-
[Neighborhood isEqualToString:]: unrecognized selector sent to
instance 0x4e35aa0'
*** Call stack at first throw:
(
0 CoreFoundation 0x00ddbbe9
__exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f305c2
objc_exception_throw + 47
2 CoreFoundation 0x00ddd6fb -
[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d4d366 ___forwarding___ +
966
4 CoreFoundation 0x00d4cf22
_CF_forwarding_prep_0 + 50
5 UIKit 0x00403340 -[UILabel
setText:] + 72
6 My-RailsToIPhoneTest 0x00001ff9 -
[RootViewController tableView:cellForRowAtIndexPath:] + 281
7 UIKit 0x003587fa -
[UITableView(UITableViewInternal)
_createPreparedCellForGlobalRow:withIndexPath:] + 634
8 UIKit 0x0034e77f -
[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] +
75
9 UIKit 0x00363450 -
[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
10 UIKit 0x0035b538 -[UITableView
layoutSubviews] + 242
11 QuartzCore 0x01c99451 -[CALayer
layoutSublayers] + 181
12 QuartzCore 0x01c9917c
CALayerLayoutIfNeeded + 220
13 QuartzCore 0x01c9237c
_ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
14 QuartzCore 0x01c920d0
_ZN2CA11Transaction6commitEv + 292
15 UIKit 0x002e719f -[UIApplication
_reportAppLaunchFinished] + 39
16 UIKit 0x002e7659 -[UIApplication
_runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:]
+ 690
17 UIKit 0x002f1db2 -[UIApplication
handleEvent:withNewEvent:] + 1533
18 UIKit 0x002ea202 -[UIApplication
sendEvent:] + 71
19 UIKit 0x002ef732
_UIApplicationHandleEvent + 7576
20 GraphicsServices 0x01711a36
PurpleEventCallback + 1550
21 CoreFoundation 0x00dbd064
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
22 CoreFoundation 0x00d1d6f7
__CFRunLoopDoSource1 + 215
23 CoreFoundation 0x00d1a983 __CFRunLoopRun +
979
24 CoreFoundation 0x00d1a240
CFRunLoopRunSpecific + 208
25 CoreFoundation 0x00d1a161 CFRunLoopRunInMode
+ 97
26 UIKit 0x002e6fa8 -[UIApplication
_run] + 636
27 UIKit 0x002f342e UIApplicationMain
+ 1160
28 My-RailsToIPhoneTest 0x00001ab4 main + 102
29 My-RailsToIPhoneTest 0x00001a45 start + 53

In the case of JSON, I get this error.

2011-02-03 02:15:44.017 My-RailsToIPhoneTest[941:207] <=
2011-02-03 02:15:44.018 My-RailsToIPhoneTest[941:207] Error
Domain=org.brautaset.JSON.ErrorDomain Code=11 "Unexpected end of
string" UserInfo=0x4e18920 {NSLocalizedDescription=Unexpected end of
string}
2011-02-03 02:15:44.018 My-RailsToIPhoneTest[941:207] count = 0

Nielson Rolim

unread,
Feb 3, 2011, 9:18:11 AM2/3/11
to objectiv...@googlegroups.com
Is it possible use a NSDate type?

I think you need to use a NSString and then convert ir to a NSDate.


--
You received this message because you are subscribed to the Google Groups "ObjectiveResource" group.
To post to this group, send email to objectiv...@googlegroups.com.
To unsubscribe from this group, send email to objectiveresou...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/objectiveresource?hl=en.




--
Nielson Rolim
nielso...@gmail.com

Jack Nutting

unread,
Feb 3, 2011, 11:59:14 AM2/3/11
to objectiv...@googlegroups.com
Based on line 6 of the crash backtrace, I'd guess you're trying to
assign a Neighborhood instance to a label by mistake. For example, you
might be doing this:

cell.detailLabel.text = neighborhood;

when you mean to do this:

cell.detailLabel.text = neighborhood.name;

Take a look at your tableView:cellForRowAtIndexPath: method and you'll
probably find the problem.

> --
> You received this message because you are subscribed to the Google Groups "ObjectiveResource" group.
> To post to this group, send email to objectiv...@googlegroups.com.
> To unsubscribe from this group, send email to objectiveresou...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/objectiveresource?hl=en.
>
>

--
// jack
// http://nuthole.com
// http://learncocoa.org

Wes Duff

unread,
Feb 4, 2011, 10:43:32 PM2/4/11
to objectiv...@googlegroups.com

Also put your neighborhoodId:String in there and dont add the blank username and password. Just delete those lines.

Remove all instances to neiborhood ni your code, except for the viewdidload method.

On Feb 3, 2011 10:59 AM, "Jack Nutting" <jnut...@gmail.com> wrote:

Based on line 6 of the crash backtrace, I'd guess you're trying to
assign a Neighborhood instance to a label by mistake. For example, you
might be doing this:

 cell.detailLabel.text = neighborhood;

when you mean to do this:

 cell.detailLabel.text = neighborhood.name;

Take a look at your tableView:cellForRowAtIndexPath: method and you'll
probably find the problem.


On Thursday, February 3, 2011, aidan james <bbftso...@gmail.com> wrote:
> Hello,

> I need some h...


--
You received this message because you are subscribed to the Google Groups "ObjectiveResource" g...

Reply all
Reply to author
Forward
0 new messages