I am having some issues with my protocol & delegate that I have set up in my app.
I am trying to return some data from a class back to a viewcontroller, however when I try to send it back nothing happens… The protocol method is never entered.
I have been over the way have set it up several times using this as a reference and just cannot see where I am making the error, So I thought if I share my code maybe someone here might be able to see what I cannot.
Heres the code I have written.
SendingClass.h
@protocol SearchViewCachedData <NSObject>
- (void)sendMyArray:(NSArray *)array;
@end
//..
__weak id <SearchViewCachedData> SearchViewDelegate;
//..
@property (weak, nonatomic) id <SearchViewCachedData> SearchViewDelegate;
//..
SendingClass.m
@synthesize SearchViewDelegate;
//..
[[self SearchViewDelegate]sendMyArray:dictionaryArray];
SearchView.h
@interface SearchViewController : UITableViewController <SearchViewCachedData> {
SearchView.m
- (void)sendMyArray:(NSArray *)array
{
//Break point in here.. but its never reached.
}
Going abit bonkers here so any help what so ever would be greatly appreciated.
I have a feeling your delegate is not set
Check to make sure searchViewDelegate is set to an instance value
Also. Properties should have their first case lower case. Classes are the items that are Capitalized.
amendment
It may be getting set to nil by another part in code or you may not be setting it at all.
where you synthesize your delegate you can create a setter as well.