undeclared object but everything implemented - iphone

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.

Related

ARC Semantic Issue: No visible #interface for Class declares the selector

Pretty basic stuff but i am unable to troubleshoot where the problem is. In my project, i have a class named "TheFeedStore" with following two methods:
- (BOOL)hasItemBeenRead:(RSSItem *)item
{
............
}
- (void)markItemAsRead:(RSSItem *)item
{
.........
}
I am using the following class method so other classes can access these methods using it:
+ (TheFeedStore *) sharedStore
{
static TheFeedStore *feedStore = nil;
if (!feedStore) {
feedStore = [[TheFeedStore alloc] init];
}
return feedStore;
}
In one of my another class, i can easily access the above methods by writing
if ([[TheFeedStore sharedStore] hasItemBeenRead:item])
or
[[TheFeedStore sharedStore] markItemAsRead:entry];
But in another class if i try to access these methods in a similar manner, i get the error "No visible #interface for 'TheFeedStore' declares the selector 'hasItemBeenRead:"
1) I have imported TheFeedStore.h file in the classes from i am
accessing these methods of TheFeedStore class.
2) I have checked like 10 times and there is no typo.
3) The methods i am accessing are also declared in the header file of
TheFeedStore.h
UPDATE: Just to check, i have declared another test method in TheFeedStore.h, same result, one class can access the newly created method while rest of the three classes cannot.
UPDATE: I have tried creating more methods in the TheFeedStore.h just for troubleshooting this issue. The new methods are also not accessible from the other classes. But if the return type of these new methods is (RSSChannel*) which is another model class in my project, than they become accessible. If their return type is other than some class like (void) and (BOOL) then they are not accessible. Here is my TheFeedStore.h https://gist.github.com/jessicamoore112/5558473
You have said that you are using #class instead of #import in your header files, the methods that you are trying to access are declared in the header files and there are no typos of any kind.
In such cases, usually no body points this issue but i am going to do it anyway because i have faced such issues many times. You have probably created many copies of your project to work on each functionality and also keeping a working project.
When you do this, sometimes Xcode is still using the older copies of few files. That means it is still using the older copy of the TheFeedStore.h when the methods you are trying to access were not declared by you.
How to solve this problem is very simple. Go to the file from which you are trying to access the methods and the files in which these methods are declared.
In the Utilities section on the right hand side, check the location and full path under "Identity and Type" area.
First check the names of the project, if it is different from the project name that you are working on, that means Xcode is still pulling the old copies of the files from the previous revision of your project. See the blue arrows where the project name is 13SampleMoreRequests in my case.
If this name is same as your project name, then my answer does not solve your problem. If its different, you should use the new copies of the file by browsing the new location using the sign that is pointed out by red arrow.
Once you browse and use the new files, your problem will be solved and you will be able to access the methods. If you still can't, copy these files, delete from the project and then add them again and you won't face this problem.
Hope this helps!
Cyclical imports, e.g. A.h imports B.h while also B.h imports A.h is the most common problem.
In C, cyclical imports won't work and one of the imports will be silently ignored. Make sure you are not having a cyclical import. If you do, solve it (e.g. using forward declarations).
Import problems can be also easily inspected if you generate the preprocessed output (you can find it in one of the Xcode menus).
That might sound silly, but I have similar cases once in a while and sometimes just simple quitting and starting xcode helps, it tends to stuck sometimes.
Also, sometimes cleaning the project helps.
'Cause I have very similar to yours singleton code and it works fine.
Guys I had encountered the exact same issues. After some searching on SO and the search engine I was able to solve it.
In my Case I have four files:
RadioStation.h
RadioStation.m
ViewController.h
ViewController.m
My mistake was to place all my methods in RadioStation.m and only put my variables on radioStation.h
So when I import radioSation.h on my ViewController.m and try to define methods for button-click on my app that's where the problems started.
I got the error/warnings "ARC Semantic Issue: No visible #interface for Class declares the selector" every time I built or ran the app simulator.
My Solution was to go back to RadioStation.h file and just declare all my methods there.
Since they were already defined on RadioStation.m I was good to go.
So make sure you have properly declared your methods on the file that is going to be imported on your viewControllers.
Hope that helps.
In my case I had some very strange path entries in
Framework Search Paths
Library Search Path
(Targets -> YOUR_APP_NAME -> Build Settings in "Search Paths" section)
I removed them and the error messages are gone.

RestKit app is crashing with [NSPathStore2 stringByAppendingQueryParameters:]: unrecognized selector message

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)

Photomania- Stanford Paul Hegarty's class

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.

Parsing XML by TBXML works on demo project, but it doesnt work in my real project

I'm really need help with parsing XML by TBXML.
I created a demo project with a view has a button,when users press this button, I just call TBXML parsing function from another class.
Im doing this to test my TBXMLParsing function works correctly or not. And it works pretty well in my demo project.
Finally, after I tested it, I copy and paste the function into my real project which has a button in first view, when I click on that button then it calls TBXMLParsing function. In other words, it is basically same as demo project. However, TBXMLParsing function doesn't work. It cant traverse thru all elements.
Do you have any ideas? Thanks for helping me.
Update:
It is working if I simulate my app on real device, but it does not traverse thru the XML if I simulate it on simulator. It is so weird. However it does work on simulator if I create new project. Thus, there must be something that in my app that prevent parser XML.
Any ideas? Thank you
Update2:
NSData *data = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:#"http://dl.dropbox.com/u/37064335/ex.xml"]];
TBXML *tbxml = [[TBXML alloc] initWithXMLData:data];
[data release];
TBXMLElement *root = tbxml.rootXMLElement;
// if root element is valid
if (root) {
NSLog(#"root =%s",root->name);
This is the part messed me up. I tested in demo app, Nslog root=GetUserAccountsRespond
However in my app Nslog root= (nil-nothing printed out). Both projects are basically the same.
Ok Here is solution for anyone that might has same problem as me. The problem was because when I Analyzed(shift+command+B) my project, xcode detected some "Semantic Issue" in TBXML.m. Then I just followed xcode's guide to change "=" to "==" in 3 places where it said "Process XML"(line258,311,and458) in TBXML.m. Thus TBXML does not work, because it cant process input XML. This problem drove me crazy for 2days. Thanks Tom Bradley for TBXML
I would check that the XML document you are trying to parse is loaded correctly before passing it onto TBXML to decode. It sound to me like there is a problem with the loading code on the sim. Try outputting the file contents to the log to verify its correct.

Leaks in UIPasteboard objects

I see a lot of leaks in several UIPasteboard objects. Until today, I never heard of this class and (obviously) didn't use one myself in the program. Here's a screenshot:
What can I do to get rid of these leaks? Am I even looking at this problem correctly?
make sure to check if the problem is a UIPasteBoard instance in any 3rd party code used.
Without a stack trace, you can't do a whole lot.
UIPasteboard is used for implementing copy&paste. On the desktop it's also used for drag&drop. Besides these two tasks, I'm not really sure what else people commonly use it for, but it is a way to send snippets of data between apps (assuming both apps know to look at the pasteboard).
If this is not an application pasteboard that you have set than it is a system pasteboard so you will need to access the generalPasteBoard than get all its items and all the types for those items and set their string and data values to nil.
generalpasteboard UIPasteBoard *pb = [UIPasteboard pasteBoardWithName:UIPasteboardNameGeneral];
for (UIPasteBoardItem *pbItem in [pb items]) {
for (NSString pbType in [pbItem pasteboardTypes]) {
[pbItem setData:nil forPasteboardType:pbType];
[pbItem setValue:nil forPasteboardType:pbType];
}
}
try putting this at the beginning of your application.... Still its strange that the general pasteboard is leaking... By the way, it may also be the find pasteboard UIPasteboardNameFind (also a system pasteboard)
Note that this is for finding out if it is the general pasteboard not using in the final distributed app. Also make sure to check if the problem is a UIPastBoard instance in any 3rd party code used.