Reputation: 4129
I've got a problem with calling methods in external files which I have imported into my project. The methods are for some reason not being called, even though the project compiles ok. And there is no error message/ output in the console.
Can someone help?? Here's the full problem:
(1) I downloaded the Flickr API (4 files) written by the author of this tutorial and drag&dropped into the Xcode file manager, specifying to copy and link the 4 files with my project.
* Flickr.h
* Flickr.m
* FlickrPhoto.h
* FlickrPhoto.m
(2) In the main view controller, I first import the external files
#import "Flickr.h"
#import "FlickrPhoto.h"
(3) Then I define a property to hold the object, in the @interface section:
@property (weak, nonatomic) Flickr *flickr;
(4) In viewDidLoad, I allocate a new instance of the object:
self.flickr = [[Flickr alloc] init];
(5) Then in a later method, I call one of the methods in the API:
[self.flickr searchFlickrForTerm:textField.text completionBlock:^(...) { ... }];
However, the method is not getting called: I have put a NSLog line right before this method call, and it prints to console. I also put an NSLog in the first line of the method:
- (void)searchFlickrForTerm:(...) term completionBlock: ...
and it is not printing anything.
Why is this method not being called???!!! Never had this problem before. Its really annoying.
Upvotes: 2
Views: 432
Reputation: 3861
Try changing your property to be strong instead of weak, and see if that fixes your issue:
@property (strong, nonatomic) Flickr *flickr;
If that fixes it, the issue was your property was being deallocated before you were able to use it. You wouldn't see any error, because a "weak" property ensures that a pointer is set to nil once the object is deallocated (and Objective-C doesn't throw errors on sending messages to nil).
Upvotes: 4