mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Add a few MacOS-X methods
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17222 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a9ba824543
commit
4b799fd922
5 changed files with 149 additions and 0 deletions
|
@ -442,6 +442,59 @@ static SEL appSel;
|
|||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Initialises the dictionary with the contents of the specified URL,
|
||||
* which must contain a dictionary in property-list format.
|
||||
* </p>
|
||||
* <p>In GNUstep, the property-list format may be either the OpenStep
|
||||
* format (ASCII data), or the MacOS-X format (URF8 XML data) ... this
|
||||
* method will recognise which it is.
|
||||
* </p>
|
||||
* <p>If there is a failure to load the URL for any reason, the receiver
|
||||
* will be released and the method will return nil.
|
||||
* </p>
|
||||
* <p>Works by invoking [NSString-initWithContentsOfURL:] and
|
||||
* [NSString-propertyList] then checking that the result is a dictionary.
|
||||
* </p>
|
||||
*/
|
||||
- (id) initWithContentsOfURL: (NSURL*)aURL
|
||||
{
|
||||
NSString *myString;
|
||||
|
||||
myString = [[NSString allocWithZone: NSDefaultMallocZone()]
|
||||
initWithContentsOfURL: aURL];
|
||||
if (myString == nil)
|
||||
{
|
||||
DESTROY(self);
|
||||
}
|
||||
else
|
||||
{
|
||||
id result;
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
result = [myString propertyList];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
result = nil;
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
RELEASE(myString);
|
||||
if ([result isKindOfClass: NSDictionaryClass])
|
||||
{
|
||||
self = [self initWithDictionary: result];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSWarnMLog(@"Contents of URL '%@' does not contain a dictionary",
|
||||
aURL);
|
||||
DESTROY(self);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a dictionary using the file located at path.
|
||||
* The file must be a property list containing a dictionary as its root object.
|
||||
|
@ -452,6 +505,16 @@ static SEL appSel;
|
|||
initWithContentsOfFile: path]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a dictionary using the contents of aURL.
|
||||
* The URL must be a property list containing a dictionary as its root object.
|
||||
*/
|
||||
+ (id) dictionaryWithContentsOfURL: (NSURL*)aURL
|
||||
{
|
||||
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithContentsOfURL: aURL]);
|
||||
}
|
||||
|
||||
- (BOOL) isEqual: other
|
||||
{
|
||||
if (other == self)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue