This repository has been archived by the owner on Aug 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathNSXMLNode+ORSTwitterDMAdditions.m
116 lines (93 loc) · 3.28 KB
/
NSXMLNode+ORSTwitterDMAdditions.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//
// NSXMLNode+ORSTwitterDMAdditions.m
// Twitter Engine
//
// Created by Nicholas Toumpelis on 12/04/2009.
// Copyright 2009 Ocean Road Software. All rights reserved.
//
// Version 0.7
#import "NSXMLNode+ORSTwitterDMAdditions.h"
@implementation NSXMLNode ( ORSTwitterDMAdditions )
// Returns the first XML for a given XPath
- (NSXMLNode *) firstNodeForXPath:(NSString *)xpathString {
NSError *error = nil;
NSArray *nodes = [self nodesForXPath:xpathString error:&error];
NSXMLNode *firstNode = (NSXMLNode *)[nodes objectAtIndex:0];
return firstNode;
}
// Direct Message Attributes (different from the status attributes)
// Returns the ID of the sender
- (NSString *) senderID {
return [[self firstNodeForXPath:@".//sender_id"] stringValue];
}
// Returns the ID of the recipient
- (NSString *) recipientID {
return [[self firstNodeForXPath:@".//recipient_id"] stringValue];
}
// Returns the screen name of the sender
- (NSString *) senderScreenName {
return [[self firstNodeForXPath:@".//sender_screen_name"] stringValue];
}
// Returns the screen name of the recipient
- (NSString *) recipientScreenName {
return [[self firstNodeForXPath:@".//recipient_screen_name"] stringValue];
}
// Returns the name of the sender
- (NSString *) senderName {
return [[self firstNodeForXPath:@".//sender/name"] stringValue];
}
// Returns the location of the sender
- (NSString *) senderLocation {
return [[self firstNodeForXPath:@".//sender/location"] stringValue];
}
// Returns the description of the sender
- (NSString *) senderDescription {
return [[self firstNodeForXPath:@".//sender/description"] stringValue];
}
// Returns the profile image URL of the sender
- (NSString *) senderProfileImageURL {
return [[self firstNodeForXPath:@".//sender/profile_image_url"]
stringValue];
}
// Returns the URL of the sender
- (NSString *) senderURL {
return [[self firstNodeForXPath:@".//sender/url"] stringValue];
}
// Returns the protected status of the sender
- (NSString *) senderProtected {
return [[self firstNodeForXPath:@".//sender/protected"] stringValue];
}
// Returns the followers count of the sender
- (NSString *) senderFollowersCount {
return [[self firstNodeForXPath:@".//sender/followers_count"] stringValue];
}
// Returns the name of the recipient
- (NSString *) recipientName {
return [[self firstNodeForXPath:@".//recipient/name"] stringValue];
}
// Returns the location of the recipient
- (NSString *) recipientLocation {
return [[self firstNodeForXPath:@".//recipient/location"] stringValue];
}
// Returns the description of the recipient
- (NSString *) recipientDescription {
return [[self firstNodeForXPath:@".//recipient/description"] stringValue];
}
// Returns the profile image URL of the recipient
- (NSString *) recipientProfileImageURL {
return [[self firstNodeForXPath:@".//recipient/profile_image_url"]
stringValue];
}
// Returns the URL of the recipient
- (NSString *) recipientURL {
return [[self firstNodeForXPath:@".//recipient/url"] stringValue];
}
// Returns the protected status of the recipient
- (NSString *) recipientProtected {
return [[self firstNodeForXPath:@".//recipient/protected"] stringValue];
}
// Returns the followers count of the recipient
- (NSString *) recipientFollowersCount {
return [[self firstNodeForXPath:@".//recipient/followers_count"] stringValue];
}
@end