Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Reformatting and refactoring project
Browse files Browse the repository at this point in the history
  • Loading branch information
mattt committed Jan 21, 2013
1 parent 140b01f commit 912c4bd
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

/* Begin PBXBuildFile section */
3B951FF416944D5B00BAF7F8 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B951FF316944D5B00BAF7F8 /* Cocoa.framework */; };
3B951FFE16944D5B00BAF7F8 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3B951FFC16944D5B00BAF7F8 /* InfoPlist.strings */; };
3B95200016944D5B00BAF7F8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B951FFF16944D5B00BAF7F8 /* main.m */; };
3B95200416944D5B00BAF7F8 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 3B95200216944D5B00BAF7F8 /* Credits.rtf */; };
3B95200716944D5B00BAF7F8 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B95200616944D5B00BAF7F8 /* AppDelegate.m */; };
3B95200A16944D5B00BAF7F8 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3B95200816944D5B00BAF7F8 /* MainMenu.xib */; };
3B95201216944D7000BAF7F8 /* AFOAuth1Client.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B95201116944D7000BAF7F8 /* AFOAuth1Client.m */; };
Expand All @@ -32,10 +30,8 @@
3B951FF716944D5B00BAF7F8 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
3B951FF816944D5B00BAF7F8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
3B951FFB16944D5B00BAF7F8 /* Twitter OSX Example Client-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Twitter OSX Example Client-Info.plist"; sourceTree = "<group>"; };
3B951FFD16944D5B00BAF7F8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
3B951FFF16944D5B00BAF7F8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
3B95200116944D5B00BAF7F8 /* Twitter OSX Example Client-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Twitter OSX Example Client-Prefix.pch"; sourceTree = "<group>"; };
3B95200316944D5B00BAF7F8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = "<group>"; };
3B95200516944D5B00BAF7F8 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
3B95200616944D5B00BAF7F8 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
3B95200916944D5B00BAF7F8 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -128,10 +124,8 @@
isa = PBXGroup;
children = (
3B951FFB16944D5B00BAF7F8 /* Twitter OSX Example Client-Info.plist */,
3B951FFC16944D5B00BAF7F8 /* InfoPlist.strings */,
3B951FFF16944D5B00BAF7F8 /* main.m */,
3B95200116944D5B00BAF7F8 /* Twitter OSX Example Client-Prefix.pch */,
3B95200216944D5B00BAF7F8 /* Credits.rtf */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -222,8 +216,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3B951FFE16944D5B00BAF7F8 /* InfoPlist.strings in Resources */,
3B95200416944D5B00BAF7F8 /* Credits.rtf in Resources */,
3B95200A16944D5B00BAF7F8 /* MainMenu.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -253,22 +245,6 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
3B951FFC16944D5B00BAF7F8 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
3B951FFD16944D5B00BAF7F8 /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
3B95200216944D5B00BAF7F8 /* Credits.rtf */ = {
isa = PBXVariantGroup;
children = (
3B95200316944D5B00BAF7F8 /* en */,
);
name = Credits.rtf;
sourceTree = "<group>";
};
3B95200816944D5B00BAF7F8 /* MainMenu.xib */ = {
isa = PBXVariantGroup;
children = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
// AppDelegate.h
//
// AppDelegate.h
// Twitter OSX Example Client
// Created by Enrico Ghirardi
// Copyright (c) 2011 Mattt Thompson (http://mattt.me/)
//
// Created by Enrico Ghirardi on 02/01/13.
// Copyright (c) 2013 Just a Dream. All rights reserved.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import <Cocoa/Cocoa.h>

Expand Down
50 changes: 34 additions & 16 deletions Twitter OSX Example Client/Twitter OSX Example Client/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
// AppDelegate.m
//
// AppDelegate.m
// Twitter OSX Example Client
// Created by Enrico Ghirardi
// Copyright (c) 2011 Mattt Thompson (http://mattt.me/)
//
// Created by Enrico Ghirardi on 02/01/13.
// Copyright (c) 2013 Just a Dream. All rights reserved.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "AppDelegate.h"

@implementation AppDelegate

- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
NSURL *url = [NSURL URLWithString:urlStr];
NSLog(@"Callback: %@", url);
NSDictionary *info = [NSDictionary dictionaryWithObject:url forKey:kAFApplicationLaunchOptionsURLKey];
NSNotification *notification = [NSNotification notificationWithName:kAFApplicationLaunchedWithURLNotification object:self userInfo:info];
[[NSNotificationCenter defaultCenter] postNotification:notification];
}
#pragma mark - NSApplicationDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(getUrl:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
LSSetDefaultHandlerForURLScheme((__bridge CFStringRef)@"af-twitter", (__bridge CFStringRef)[[NSBundle mainBundle] bundleIdentifier]);

self.twitterClient = [[AFOAuth1Client alloc] initWithBaseURL:[NSURL URLWithString:@"https://api.twitter.com/"] key:@"4oFCF0AjP4PQDUaCh5RQ" secret:@"NxAihESVsdUXSUxtHrml2VBHA0xKofYKmmGS01KaSs"];
Expand All @@ -34,14 +41,25 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[self.twitterClient getPath:@"1/statuses/user_timeline.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSArray *responseArray = (NSArray *)responseObject;
[responseArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
NSLog(@"obj: %@", obj);
NSLog(@"Success: %@", obj);
}];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error: %@", error);
NSLog(@"Error: %@", error);
}];
} failure:^(NSError *error) {
NSLog(@"Error: %@", error);
}];
}

#pragma mark - NSAppleEventManager

- (void)handleEvent:(NSAppleEventDescriptor *)event
withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
NSURL *url = [NSURL URLWithString:[[event paramDescriptorForKeyword:keyDirectObject] stringValue]];
NSDictionary *info = [NSDictionary dictionaryWithObject:url forKey:kAFApplicationLaunchOptionsURLKey];
NSNotification *notification = [NSNotification notificationWithName:kAFApplicationLaunchedWithURLNotification object:self userInfo:info];
[[NSNotificationCenter defaultCenter] postNotification:notification];
}

@end

This file was deleted.

27 changes: 20 additions & 7 deletions Twitter OSX Example Client/Twitter OSX Example Client/main.m
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
// main.m
//
// main.m
// Twitter OSX Example Client
// Created by Enrico Ghirardi
// Copyright (c) 2011 Mattt Thompson (http://mattt.me/)
//
// Created by Enrico Ghirardi on 02/01/13.
// Copyright (c) 2013 Just a Dream. All rights reserved.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
int main(int argc, char *argv[]) {
return NSApplicationMain(argc, (const char **)argv);
}

0 comments on commit 912c4bd

Please sign in to comment.