In the SeismicXMLAppDelegate implementation file of this class they have the following code:
// forward declarations
@interface SeismicXMLAppDelegate ()
@property (nonatomic, retain) NSURLConnection *earthquakeFeedConnection;
@property (nonatomic, retain) NSMutableData *earthquakeData; // the data returned from the NSURLConnection
@property (nonatomic, retain) NSOperationQueue *parseQueue; // the queue that manages our NSOperation for parsing earthquake data
- (void)addEarthquakesToList:(NSArray *)earthquakes;
- (void)handleError:(NSError *)error;
@end
Why do they have a second interface in the implementation file?
http://开发者_JS百科developer.apple.com/library/ios/#samplecode/SeismicXML/Listings/Classes_SeismicXMLAppDelegate_m.html#//apple_ref/doc/uid/DTS40007323-Classes_SeismicXMLAppDelegate_m-DontLinkElementID_10
This is a called an Extension (or an anonymous Category) in Objective-C
You can add properties, change its attributes and declare new methods like in that example. Why not doing it in the interface file? Well there could be a lot of reasons, for design purposes, for not to exposing some properties., etc.
For example, you cannot call myAppDelegate.earthquakeData
from RootViewController.m
even if you #import "SeismicXMLAppDelegate.h"
.
You can only access to earthquakeData
property from inside of SeismicXMLAppDelegate
class.
You can read more about Categories and Extensions here: The Objective-C Programming Language
精彩评论