-
Notifications
You must be signed in to change notification settings - Fork 0
/
EPFriendRecommenderController.m
64 lines (48 loc) · 1.71 KB
/
EPFriendRecommenderController.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
//
// EPFriendRecommenderController.m
// Degrees of Tweetdom
//
// Created by Simone Manganelli on 2008-08-26.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "EPFriendRecommenderController.h"
#import "EPFriendRecommender.h"
@implementation EPFriendRecommenderController
- (id)init;
{
if (self = [super initWithWindowNibName:@"FriendRecommender"]) {
friendRecommenderInstance = [[EPFriendRecommender alloc] initWithStatusDelegate:self];
}
return self;
}
- (void)dealloc;
{
[friendRecommenderInstance release];
[super dealloc];
}
- (void)addStatusLine:(NSString *)statusLine;
{
NSString *newStatus = [[statusConsoleView string] stringByAppendingString:[NSString stringWithFormat:@"%@\n",statusLine]];
[statusConsoleView performSelectorOnMainThread:@selector(setString:) withObject:newStatus waitUntilDone:YES];
[self performSelectorOnMainThread:@selector(scrollErrorConsoleToBottom) withObject:nil waitUntilDone:NO];
}
- (void)scrollErrorConsoleToBottom;
{
[statusConsoleView scrollRangeToVisible:NSMakeRange([[statusConsoleView string] length]-1,1)];
}
- (IBAction)startFriendRecommending:(id)sender;
{
[statusConsoleView setString:@""];
[NSThread detachNewThreadSelector:@selector(recommendSomeFriends)
toTarget:self
withObject:nil];
}
- (void)recommendSomeFriends;
{
int levelsDeep = [levelsDeepTextField intValue];
if (levelsDeep < 1) levelsDeep = 1;
NSString *recommendationString = [friendRecommenderInstance recommendFriendsForTwitterer:[twittererTextField stringValue]
levelsDeep:[NSNumber numberWithInt:levelsDeep]];
[statusConsoleView performSelectorOnMainThread:@selector(setString:) withObject:recommendationString waitUntilDone:YES];
}
@end