I am new in RestKit i am using RKObjectMapping to call service but its crashing, Error Log is
2012-07-20 18:31:58.319 SampleRest[6589:207] -[NSPathStore2 stringByAppendingQueryParameters:]: unrecognized selector sent to instance 0x6d74c20
and here is my code which i written :
-(void) callService {
RKObjectMapping *rk = [RKObjectMapping mappingForClass:[vo class]];
[rk mapKeyPath:#"id" toAttribute:#"primaryKey"];
[rk mapKeyPath:#"opposing_team_name" toAttribute:#"opp_team_name"];
RKObjectManager *rkManager = [RKObjectManager objectManagerWithBaseURLString: #"http://hercules.softwaytechnologies.com/sportsapp_v3.0"];
[rkManager loadObjectsAtResourcePath:#"/event_games/get?application_id=1" delegate:self];
}
Please help, am i doing any mistake?
Thanks in advance
I've had the same problem and have found that the process of adding RestKit is painful and therefore confusing.
I noticed that the linker flag -ObjC, although I know I set it, was no longer applied to my target!
Once I set other linker flags to -ObjC -all_load all was well.
So what I suggest is double check and double check again with this!
The other areas I've had issues with is where to add the source files for RestKit physically. I don't follow the instructions to add it as a sub of my repo because I'm using Mercurial and found it all just messed up.
Eventually I find that copying the whole contents of the original RestKit folder into the base folder holding my solution works.
I all seems a bit messy - although when you drop the RestKit proj file into xCode it all appears neatly arranged in its folders.
(If someone could suggest a better way of doing this -which works!!- I'd like to know, thanks)
Related
is there something wrong with core data for xcode 4.3.2
I'm following the Stanford Paul Hegarty class for ios 5.0
doing the core data walkthrough (Video 14 Core data demo)
I downloaded the file here
I ran it in xcode 4.3.2 but the core data doesn't seem to work because the entries in the tableview do not appear.
I tried to run it in another computer with xcode 4.2 and ios 5.0
it's working perfectly
anybody who encountered the same problem? I'm pretty sure that xcode is at fault.
Interesting. I am having the same problems and I am also using XCode 4.3, but just thought it was because of the Flickr license that you need and which I don't have. (In FlickAPIKey.h, there is a #define FlickrAPIKey #"" and you won't download anything if you don't have that key.)
Update: I got myself a Flickr API key (you can just get one from their website) and tried the Photomania App on XCode 4.3: it works like a charm, so it looks like XCode is not your problem here. (Although on occasion I found that I had to stop and restart XCode to get rid of a strange bug or compiler error.) Anyway, maybe it is an idea to delete the data first before you try again: Just delete the App before you run it and the database file will get deleted as well.
Paul Hegarty after his class, has published an update version of his code which have a call to SAVE the CoreData database! This may be the reason why your CoreData informations doesn't persist.
His update note was:
// should probably saveToURL:forSaveOperation:(UIDocumentSaveForOverwriting)completionHandler: here!
// we could decide to rely on UIManagedDocument's autosaving, but explicit saving would be better
// because if we quit the app before autosave happens, then it'll come up blank next time we run
// this is what it would look like (ADDED AFTER LECTURE) ...
[document saveToURL:document.fileURL forSaveOperation:UIDocumentSaveForOverwriting completionHandler:NULL];
So, you have to Add the 'document saveToURL' line in the 'fetchFlickrDataInDocument' function like this:
- (void)fetchFlickrDataIntoDocument:(UIManagedDocument *)document
{
dispatch_queue_t fetchQ = dispatch_queue_create("Flickr fetcher", NULL);
dispatch_async(fetchQ, ^{
NSArray *photos = [FlickrFetcher recentGeoreferencedPhotos];
[document.managedObjectContext performBlock:^{
// perform in the NSMOC's safe thread (main thread)
for (NSDictionary *flickrInfo in photos) {
[Photo photoWithFlickrInfo:flickrInfo inManagedObjectContext:document.managedObjectContext];
// table will automatically update due to NSFetchedResultsController's observing of the NSMOC
}
// should probably saveToURL:forSaveOperation:(UIDocumentSaveForOverwriting)completionHandler: here!
// we could decide to rely on UIManagedDocument's autosaving, but explicit saving would be better
// because if we quit the app before autosave happens, then it'll come up blank next time we run
// this is what it would look like (ADDED AFTER LECTURE) ...
[document saveToURL:document.fileURL forSaveOperation:UIDocumentSaveForOverwriting completionHandler:NULL];
// note that we don't do anything in the completion handler this time
}];
});
}
If someone is still facing the same issue using Objective-C, there is one more thing you need to do after getting API key: change all http:// to https:// within files in FlickrFetcher folder. This worked for me.
i implemented first three20 (first, with the python scrip) and then restkit (second,manual).
i started adding some stuff to my app delegate, but then i get an error [RKObjectLoaderTTModel undeclared. Other Objects RKClient or RKObjectManager work fine.
// work
[RKClient clientWithBaseURL:APP_BASE_URL username:USER_EMAIL password:USER_PASSWORD];
RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:APP_BASE_URL];
//fail
[RKObjectLoaderTTModel setDefaultRefreshRate:1];
looking into RestKit/Build/RestKit/Three20 i can see RKObjectLoaderTTModel header.
i added all header search paths, etc , pp.
i think you get a better view, when looking into my project, sohere is it (have nothing done yet, so no problem with sharing): http://dl.dropbox.com/u/80699/project_for_stack.zip
hopefully somebody can help.
#import <RestKit/Three20/Three20.h>
had to import explicit the restkit three20 stuff.
hope this helps somebody. now everything runs fine.
Do you have any idea?
Why XCode compilation give this result?
ld: duplicate symbol _kJSONDeserializerErrorDomain in
/Users/Shared/_BUILDS_/Debug-iphoneos/libLACDLibrary.a(CJSONDeserializer.o)
and /Users/Shared/_BUILDS_/Debug-iphoneos/libLACDLibrary.a(CJSONDeserializer.o)
I have exactly the same problem. And it only complains for arm6 build (not arm7 build). I found a workaround: remove "-all_load" in Other linker flag under Build<-Get Info<-Target. I am not sure whether it is a correct workaround. I hope somebody can explain further and provide the correct workaround if this one is not.
This error occurs if you link the same library into your project multiple times.
Project dependencies are subtly different from linking the libraries together. It is okay to have several projects depend on the same shared library project X; however, make sure that only one of the projects actually links the library.
Hey, you probably have a duplicate reference in XCode to CJSONDeserializer, so it's compiled and linked twice.
I hit this issue with code like the following in a file called Common.h:
void dumpViews(UIView* view, NSString *text, NSString *indent) {
// ...
}
By adding static in front of the method definition it cleared the problem up for me:
static void dumpViews(UIView* view, NSString *text, NSString *indent) {
// ...
}
We're integrating a library into an iPhone app which appears to use the google toolbox for iPhone internally.
The google toolbox adds a method gtm_stringBySanitizingAndEscapingForXML to NSString.
The problem is, whenever we attempt to make a call to this library we get
[NSCFString gtm_stringBySanitizingAndEscapingForXML]: unrecognized selector sent to instance 0x272478
So it appears the library is calling that method on a NSCFString, to which the category does not apply.
So... is it the case that the category will not apply across the toll-free bridge to CoreFoundation classes?
If that's the case then we at least know why it's blowing up. Figuring out how to fix it is a different matter.
Categories applied to NSString do apply to NSCFString as well, because NSCFString is a subclass of NSMutableString which is a subclass of NSString.
But have you actually included the Google Toolbox library (GTMNSString+XML.m)?
NSCFString class is not a subclass of NSMutableString... It's just another class of NSString cluster. So if you have a NSCFString foo var and you test this:
BOOL isNSString = [foo isKindObClass:[NSString class]];
You will get that isNSString is NO.
I'm experiencing some problems because I've created a NSString category and I don't know how to apply the new methods when the class is a NSCFString or any other class from that cluster...
EDIT:
Ok, I found the solution. Although those tests returned NO:
[myString isKindOfClass:[NSString class]];
[myString respondsToSelector:#selector(myNSStringCategorySelector:)];
I forced the execution of the method for the NSCFString class, and it worked correctly!!
I hope it'll help someone!
Sounds like the implementation of this category is not linked into your program. Assuming that your library is compiled as a static library you might need to add the -ObjC linker flag to your project. For more information take a look at this technote. The linker bug mentioned in there should be fixed with the latest Xcode release.
I have created a static library to house some of my code like categories.
I have a category for UIViews in "UIView-Extensions.h" named Extensions.
In this category I have a method called:
- (void)fadeOutWithDelay:(CGFloat)delay duration:(CGFloat)duration;
Calling this method works fine on the simulator on Debug configuration.
However, if try to run the app on the device I get a NSInvalidArgumentException:
[UIView fadeOutWithDelay:duration:]: unrecognized selector sent to instance 0x1912b0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIView fadeOutWithDelay:duration:]: unrecognized selector sent to instance 0x1912b0
It seems for some reason UIView-Extensions.h is not being included in the device builds.
What I have checked/tried
I did try to include another category for NSString, and had the same issue.
Other files, like whole classes and functions work fine. It is an issue that only happens with categories.
I did a clean all targets, which did not fix the problem.
I checked the static library project, the categories are included in the target's "copy headers" and "compile sources" groups.
The static library is included in the main projects "link binary with library" group.
Another project I have added the static library to works just fine.
I deleted and re-added the static library with no luck
-ObjC linker flag is set
Any ideas?
nm output
libFJSCodeDebug.a(UIView-Extensions.o):
000004d4 t -[UIView(Extensions) changeColor:withDelay:duration:]
00000000 t -[UIView(Extensions) fadeInWithDelay:duration:]
000000dc t -[UIView(Extensions) fadeOutWithDelay:duration:]
00000abc t -[UIView(Extensions) firstResponder]
000006b0 t -[UIView(Extensions) hasSubviewOfClass:]
00000870 t -[UIView(Extensions) hasSubviewOfClass:thatContainsPoint:]
000005cc t -[UIView(Extensions) rotate:]
000002d8 t -[UIView(Extensions) shrinkToSize:withDelay:duration:]
000001b8 t -[UIView(Extensions) translateToFrame:delay:duration:]
U _CGAffineTransformRotate
000004a8 t _CGPointMake
U _CGRectContainsPoint
U _NSLog
U _OBJC_CLASS_$_UIColor
U _OBJC_CLASS_$_UIView
U ___CFConstantStringClassReference
U ___addsf3vfp
U ___divdf3vfp
U ___divsf3vfp
U ___extendsfdf2vfp
U ___muldf3vfp
U ___truncdfsf2vfp
U _objc_enumerationMutation
U _objc_msgSend
U _objc_msgSend_stret
U dyld_stub_binding_helper
The only solution that worked was to include:
"-all_load"
in other linker flags.
EDIT: Be sure to add this flag to the project including the static library, not to the static library itself.
I know this isn't the correct method, but it is working for now.
It maybe a OS 3.0 issue since this was the work around for Three20 as well.
Unfortunately, due to the what categories work and the dynamic nature of the Objective-C runtime, not everything works well with static libraries. The reason you get this error is that the category implementation in the static library is never actually linked into the executable image because the compiler has no way of knowing that the implementation code will be needed at run-time.
In order to cure this, you can force the linker to copy object files from a static archive for any and all Objective-C Class and Category images. The downside is that your executable will include image code for classes that you may not be using at all. To get the linker to include the category code, add -ObjC to the OTHER_LD_FLAGS build setting in Xcode. Your category implementation will now be copied from the static archive to your executable and you won't get the runtime exception.
I just spoke to an Apple engineer about this, and this has been addressed in ld with versions >100. This is included in Xcode 4. He walked me through this and I tried it myself and indeed the category problem is fixed.
Take out "-all_load" and go back to "-ObjC" in your Build Settings with the new linker.
If you are on Xcode 3.2 you can avoid using -all_load and instead use -force_load for just the library in question, which should be slightly more efficient.
This is described in a recently updated Apple Technical QA: http://developer.apple.com/mac/library/qa/qa2006/qa1490.html
The issue that -all_load or -force_load linker flags were needed to link categories has been fixed in LLVM. The fix ships as part of LLVM 2.9 The first Xcode version to contain the fix is Xcode 4.2 shipping with LLVM 3.0. The mentioned fixes are no longer needed when working with Xcode 4.2. The -ObjC flag is still needed when linking ObjC binaries
I ran into this problem recently. I was unable to get the -all_load to work, when I noticed that another category I had DID work. I was lazy for this category and included it in with another file.
I eventually created a dummy class (no methods, instance variables) and included the implementation of my categories in the .m file for that dummy class. After doing this my categories started working even after I removed the -all_load flag.
This was on iPhone OS 3.1.3.
This certainly is not the RIGHT way to fix it, but it seemed to work.
Full sample code is on my blog for my (trivial) categories.
I just had this same problem but adding any combination of the described flags (-ObjC, -all_load, -force_load) did not work.
It turned out that I had not checked the box "Add to Target" when adding the files to the project. I removed the files from the project and added them again, this time making sure that that box was checked. This fixed the problem.
In the past I was able to force linkage of the category with -u .objc_category_name_UIView_Extensions, but with the 3.0 dev environment that's broken and the only option seems to be -all_load.
I had the same problem with Categories in my static library. In my case, "-all_load" didn't help as it caused loads of build errors (my static library is a wrapper around another private C/C++ lib).
I solved it by a hack suggested at http://iphonedevelopmentexperiences.blogspot.com/2010/03/categories-in-static-library.html which simply involved adding a dummy (empty) class definition to the category files. Using this hack, I kept "-ObjC" but dropped "-all_load" in the application linker settings and it worked fine on the device.