forked from MRRSoftware/Tardis
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCHGitHub.m
executable file
·58 lines (42 loc) · 1.4 KB
/
CHGitHub.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
//
// MSOEngine.m
// MSOEngine
//
// Created by Matt on 4/6/10.
// Copyright 2010 Matt's Apps. All rights reserved.
//
#import "CHGitHub.h"
@implementation CHGitHub
-(NSString*)initWithDataforURL:(NSString *)data
{
NSString *theURL = [[NSString alloc] initWithFormat:@"%@%@", _url, data];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:theURL]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
// Get JSON as a NSString from NSData response
NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
return json_string;
}
-(void)initWithURL:(NSString *)newurl
{
[_url release];
_url = [newurl retain];
}
-(NSString *)connectMekThxBai:(NSString *)data firstkey:(NSString *)key1 secondkey:(NSString *)key2
{
NSMutableArray *array;
array = [[NSMutableArray alloc] init];
SBJSON *parser = [[SBJSON alloc] init];
NSMutableDictionary *jsonObj = [parser objectWithString:data error:nil];
NSString *two = [[jsonObj objectForKey:key1] valueForKey:key2];
return two;
}
-(NSString *)getUserData:(NSString*)key forData:(NSString *)data
{
// NSString *theURL = [[NSString alloc] initWithFormat:@"%@users/%d?key=%@",_url, theID, _apikey];
NSString *result = [self connectMekThxBai:data
firstkey:@"user"
secondkey:key];
// NSLog(@"%@", result);
return result;
}
@end