Attachment | Size |
---|---|
![]() | 75.99 KB |
- Sort Posts
- 2 replies
- Last post
#DEBUG bad Target
#DEBUG bad Target
yes i did and when detecting the marker it logs with
Successfully created new trackable 'track name' with rating '4'.
-(void)infoRequestDidFinishForBook:(Book *)theBook withTrackableID:(const char*)trackable byCancelling:(BOOL)cancelled
{
if (theBook) // nill
{
trackingTextureAvailable = NO;
[[ImagesManager sharedInstance] imageForBook:theBook
withDelegate:self];
NSLog(@"a >> %@",theBook.author);
NSLog(@"b >> %@",theBook.bookURL);
NSLog(@"c >> %f",theBook.listPrice);
NSLog(@"d >> %@",theBook.listPriceString);
NSLog(@"e >> %@",theBook.thumbnailURL);
NSLog(@"f >> %@",theBook.title);
NSLog(@"g >> %f",theBook.yourPrice);
NSLog(@"h >> %@",theBook.targetID);
}
else
{
// so it get here
if (NO == cancelled)
{
// The trackable exists but it doesn't exist in our book database, so
// we'll mark that UniqueTargetId as a bad target
[[BooksManager sharedInstance] addBadTargetId:trackable];
}
// If theBook is nil, the loading UI would be shown forever and it
// won't scan again. Send a notification to revert that state
[[NSNotificationCenter defaultCenter] postNotificationName:@"kStopLoading" object:nil userInfo:nil];
}
}
You need to trace through the step before it gets here i.e. where it calls the delegate in BooksManager.m
Specifically this is in the method below where book starts out as nil, and it will remain so if there is a problem. Step through this to discover why it is nil.
N
-(void)infoDownloadDidFinishWithBookData:(NSData *)bookData withConnection:(NSURLConnection *)connection
{
Book *book = nil;
if (bookData)
{
// Given a NSData, parse the book to a dictionary and then convert it into a Book object
NSError *anError = nil;
NSDictionary *bookDictionary = nil;
// Find out on runtime if the device can use NSJSONSerialization (iOS5 or later)
NSString *className = @"NSJSONSerialization";
Class class = NSClassFromString(className);
if (!class)
{
// Use custom BookDataParser.
//
// IMPORTANT: BookDataParser is written to parse data specific to the Books
// sample application and is not designed to be used in other applications.
bookDictionary = [BookDataParser parseData:bookData];
NSLog(@"#DEBUG Using custom JSONBookParser");
}
else
{
// Use native JSON parser, NSJSONSerialization
bookDictionary = [NSJSONSerialization JSONObjectWithData: bookData
options: NSJSONReadingMutableContainers
error: &anError];
NSLog(@"#DEBUG Using NSJSONSerialization");
}
if (!bookDictionary)
{
NSLog(@"#DEBUG Error parsing JSON: %@", anError);
}
else
{
book = [[[Book alloc] initWithDictionary:bookDictionary] autorelease];
}
}
// Inform the delegate that the request has completed
[delegate infoRequestDidFinishForBook:book withTrackableID:[thisTrackable cStringUsingEncoding:NSASCIIStringEncoding] byCancelling:[self cancelNetworkOperation]];
// rest of code
}