this code is from a sample in .h part :
@interface ViewController : UITableViewController < NSNetServiceBrowserDelegate > {
NSMutableArray * tableData;
NSNetServiceBrowser * _browser;
NSMutableArray * _foundServices;
NSURLConnection * _connection;
NSInputStream * _consumerStream;
NSString * controllerHostName;
}
@property (nonatomic, retain) NSMutableArray * tableData;
@property (nonatomic, retain) NSNetServiceBrowser * _browser;
@property (nonatomic, retain) NSMutableArray * _foundServices;
@property (nonatomic, retain) NSURLConnection * connection;
@property (nonatomic, retain) NSInputStream * consumerStream;
@property (nonatomic, retain) NSString * controllerHostName;
in the .m part
#import "ViewController.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <CFNetwork/CFNetwork.h>
@synthesize tableData;
@synthesize _browser;
@synthesize _foundServices;
@synthesize consumerStream = _consumerStream;
@synthesize connection = _connection;
@synthesize controllerHostName;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
_browser = [[NSNetServiceBrowser alloc] init];
[_browser setDelegate:self];
[_browser searchForServicesOfType:@"_service._tcp" inDomain:@""];
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[_browser stop];
_browser.delegate = nil;
[_browser release];
_browser = nil;
[_foundServices removeAllObjects];
}
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser didFindService:(NSNetService *)netService moreComing:(BOOL)moreServicesComing
{
self.controllerHostName = [NSString stringWithFormat:@"%@.%@", netService.name, netService.domain];
NSLog(@"ControllerHost String is: %@", self.controllerHostName);
NSLog(@"URL to use is === %@.%@", netService.name, netService.domain);
if (!_foundServices) {
_foundServices = [[NSMutableArray alloc] init];
}
[_foundServices addObject:netService];
[self.tableView reloadData];
}
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser didRemoveService:(NSNetService *)netService moreComing:(BOOL)moreServicesComing
{
[_foundServices removeObject:netService];
}
- (void)netServiceBrowserDidStopSearch:(NSNetServiceBrowser *)aNetServiceBrowser
{
[_foundServices removeAllObjects];
}
I declaration all the header as the sample does But I got error message "Cannot find protocol declaration for "NSNetServiceDelegate" in .h
interface ViewController : UITableViewController < NSNetServiceBrowserDelegate >
So did I missing anything to declaration ? The sample doesn't has any warning or error