Skip to content

Commit

Permalink
We now no longer obfuscate the fact that this code compiles for iPhon…
Browse files Browse the repository at this point in the history
…e too.
  • Loading branch information
mattgemmell committed Oct 1, 2008
1 parent 8a144c8 commit f9e2446
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 34 deletions.
7 changes: 4 additions & 3 deletions MGTwitterEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ + (NSString *)version
// 1.0.5 = 06 Jun 2008
// 1.0.6 = 05 Aug 2008
// 1.0.7 = 28 Sep 2008
return @"1.0.7";
// 1.0.8 = 01 Oct 2008
return @"1.0.8";
}


Expand Down Expand Up @@ -700,8 +701,8 @@ - (void)connectionDidFinishLoading:(MGTwitterHTTPURLConnection *)connection

if ([connection responseType] == MGTwitterImage) {
// Create image from data.
#if MG_ALT_PLATFORM
MG_ALT_PLATFORM_IMAGE_CLASS *image = [[[MG_ALT_PLATFORM_IMAGE_CLASS alloc] initWithData:[connection data]] autorelease];
#if TARGET_OS_IPHONE
UIImage *image = [[[UIImage alloc] initWithData:[connection data]] autorelease];
#else
NSImage *image = [[[NSImage alloc] initWithData:[connection data]] autorelease];
#endif
Expand Down
4 changes: 2 additions & 2 deletions MGTwitterEngineDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
- (void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString *)identifier;
- (void)miscInfoReceived:(NSArray *)miscInfo forRequest:(NSString *)identifier;

#if MG_ALT_PLATFORM
- (void)imageReceived:(MG_ALT_PLATFORM_IMAGE_CLASS *)image forRequest:(NSString *)identifier;
#if TARGET_OS_IPHONE
- (void)imageReceived:(UIImage *)image forRequest:(NSString *)identifier;
#else
- (void)imageReceived:(NSImage *)image forRequest:(NSString *)identifier;
#endif
Expand Down
30 changes: 4 additions & 26 deletions MGTwitterEngineGlobalHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,12 @@
//

/*
The first section of this global header allows you to make MGTwitterEngine work with
target platforms other than Mac OS X. To do so, your target platform should be supported
for development on Mac OS X, and should have a preset definition to indicate that it
is currently being compiled for.
Your target platform should also include an image-object class which is API-compatible with
the NSImage class from Cocoa's AppKit framework. You can create a wrapper class if needed.
To compile for that platform, you would:
1. Ensure appropriate frameworks etc are linked in your Xcode project.
2. Change "TARGET_OS_MG_NEW_COOL_PLATFORM" below to the platform's actual target definition.
3. Change the "MGBaseFramework" and "MGAppFramework" imports below to reflect actual frameworks.
4. Change "MGImage" below to the actual class-name of the NSImage-like image class on your platform.
5. If your platform includes LibXML and you plan to use it, ensure that libxml is appropriately linked,
and that appropriate Header Search Paths are set in your project.
This file conditionally includes the correct headers for either Mac OS X or iPhone deployment.
*/

#if TARGET_OS_MG_NEW_COOL_PLATFORM // for example
#import <MGBaseFramework/MGBaseFramework.h> // for example
#import <MGAppFramework/MGAppFramework.h> // for example
#define MG_ALT_PLATFORM_IMAGE_CLASS "MGImage" // for example

#define MG_ALT_PLATFORM 1 // DO NOT CHANGE
#if TARGET_OS_IPHONE
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
14 changes: 11 additions & 3 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,18 @@ In this case, you make need to make the following changes to your project:



A note about using MGTwitterEngine on other target platforms
============================================================
A note about using MGTwitterEngine on the iPhone
================================================

MGTwitterEngine can potentially be used on other platforms which are supported for Cocoa development on Mac OS X. To find out more about this, please read the notes in the MGTwitterEngineGlobalHeader.h file.
MGTwitterEngine can also be used on the iPhone (with the official iPhone SDK). Simply add it to your iPhone application project as usual.

It's recommended that you use the LibXML parser rather than the NSXMLParser on the iPhone. The native parser is faster and has a smaller memory footprint, and every little bit counts on the device. If you configure USE_LIBXML to 1 in MGTwitterEngine.m, you'll need to make a couple of additions to your project.

1. Add libxml2.dylib in Other Frameworks. You'll find the library in:

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/lib/libxml2.dylib

2. Add "$SDKROOT/usr/include/libxml2" as a Header Search Path in your Project Settings.



Expand Down

0 comments on commit f9e2446

Please sign in to comment.