[api][ios] Capitals example

This commit is contained in:
Alex Zolotarev 2013-07-01 04:00:25 +03:00 committed by Alex Zolotarev
parent ac97f282d4
commit b7be01f495
27 changed files with 1682 additions and 277 deletions

View file

@ -0,0 +1,382 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
FA1792CE17784F000092B567 /* MapsWithMeAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = FA1792CC17784F000092B567 /* MapsWithMeAPI.m */; };
FA776B4F17848A370023F7A0 /* MasterViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = FA776B4D17848A370023F7A0 /* MasterViewController.xib */; };
FAA484EA178108970027B232 /* 114x114.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA484E2178108970027B232 /* 114x114.png */; };
FAA484EB178108970027B232 /* 144x144.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA484E3178108970027B232 /* 144x144.png */; };
FAA484EC178108970027B232 /* 100x100.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA484E4178108970027B232 /* 100x100.png */; };
FAA484ED178108970027B232 /* 72x72.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA484E5178108970027B232 /* 72x72.png */; };
FAA484EE178108970027B232 /* 58x58.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA484E6178108970027B232 /* 58x58.png */; };
FAA484EF178108970027B232 /* 57x57.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA484E7178108970027B232 /* 57x57.png */; };
FAA484F0178108970027B232 /* 50x50.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA484E8178108970027B232 /* 50x50.png */; };
FAA484F1178108970027B232 /* 29x29.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA484E9178108970027B232 /* 29x29.png */; };
FAD3DD4F177221B500B0735B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAD3DD4E177221B500B0735B /* UIKit.framework */; };
FAD3DD51177221B500B0735B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAD3DD50177221B500B0735B /* Foundation.framework */; };
FAD3DD53177221B500B0735B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAD3DD52177221B500B0735B /* CoreGraphics.framework */; };
FAD3DD5B177221B500B0735B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FAD3DD5A177221B500B0735B /* main.m */; };
FAD3DD5F177221B500B0735B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FAD3DD5E177221B500B0735B /* AppDelegate.m */; };
FAD3DD61177221B500B0735B /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = FAD3DD60177221B500B0735B /* Default.png */; };
FAD3DD63177221B500B0735B /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FAD3DD62177221B500B0735B /* Default@2x.png */; };
FAD3DD65177221B500B0735B /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FAD3DD64177221B500B0735B /* Default-568h@2x.png */; };
FAD3DD68177221B500B0735B /* MasterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FAD3DD67177221B500B0735B /* MasterViewController.m */; };
FAD3DD7F1772246600B0735B /* City.m in Sources */ = {isa = PBXBuildFile; fileRef = FAD3DD7E1772246600B0735B /* City.m */; };
FAD3DD8317724D4A00B0735B /* CityDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FAD3DD8117724D4A00B0735B /* CityDetailViewController.m */; };
FAD3DD8417724D4A00B0735B /* CityDetailViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = FAD3DD8217724D4A00B0735B /* CityDetailViewController.xib */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
FA1792CC17784F000092B567 /* MapsWithMeAPI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MapsWithMeAPI.m; path = ../src/MapsWithMeAPI.m; sourceTree = "<group>"; };
FA1792CD17784F000092B567 /* MapsWithMeAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MapsWithMeAPI.h; path = ../src/MapsWithMeAPI.h; sourceTree = "<group>"; };
FA776B4D17848A370023F7A0 /* MasterViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MasterViewController.xib; sourceTree = "<group>"; };
FAA484E2178108970027B232 /* 114x114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 114x114.png; sourceTree = "<group>"; };
FAA484E3178108970027B232 /* 144x144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 144x144.png; sourceTree = "<group>"; };
FAA484E4178108970027B232 /* 100x100.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 100x100.png; sourceTree = "<group>"; };
FAA484E5178108970027B232 /* 72x72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 72x72.png; sourceTree = "<group>"; };
FAA484E6178108970027B232 /* 58x58.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 58x58.png; sourceTree = "<group>"; };
FAA484E7178108970027B232 /* 57x57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 57x57.png; sourceTree = "<group>"; };
FAA484E8178108970027B232 /* 50x50.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 50x50.png; sourceTree = "<group>"; };
FAA484E9178108970027B232 /* 29x29.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 29x29.png; sourceTree = "<group>"; };
FAD3DD4B177221B500B0735B /* Capitals.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Capitals.app; sourceTree = BUILT_PRODUCTS_DIR; };
FAD3DD4E177221B500B0735B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
FAD3DD50177221B500B0735B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
FAD3DD52177221B500B0735B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
FAD3DD56177221B500B0735B /* Capitals-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Capitals-Info.plist"; sourceTree = "<group>"; };
FAD3DD5A177221B500B0735B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
FAD3DD5C177221B500B0735B /* Capitals-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Capitals-Prefix.pch"; sourceTree = "<group>"; };
FAD3DD5D177221B500B0735B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
FAD3DD5E177221B500B0735B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
FAD3DD60177221B500B0735B /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
FAD3DD62177221B500B0735B /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = "<group>"; };
FAD3DD64177221B500B0735B /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
FAD3DD66177221B500B0735B /* MasterViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MasterViewController.h; sourceTree = "<group>"; };
FAD3DD67177221B500B0735B /* MasterViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MasterViewController.m; sourceTree = "<group>"; };
FAD3DD7D177223BB00B0735B /* City.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = City.h; sourceTree = "<group>"; };
FAD3DD7E1772246600B0735B /* City.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = City.m; sourceTree = "<group>"; };
FAD3DD8017724D4A00B0735B /* CityDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CityDetailViewController.h; sourceTree = "<group>"; };
FAD3DD8117724D4A00B0735B /* CityDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CityDetailViewController.m; sourceTree = "<group>"; };
FAD3DD8217724D4A00B0735B /* CityDetailViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CityDetailViewController.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
FAD3DD48177221B500B0735B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FAD3DD4F177221B500B0735B /* UIKit.framework in Frameworks */,
FAD3DD51177221B500B0735B /* Foundation.framework in Frameworks */,
FAD3DD53177221B500B0735B /* CoreGraphics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
FA1792C7177843650092B567 /* MapsWithMe API */ = {
isa = PBXGroup;
children = (
FA1792CD17784F000092B567 /* MapsWithMeAPI.h */,
FA1792CC17784F000092B567 /* MapsWithMeAPI.m */,
);
name = "MapsWithMe API";
sourceTree = "<group>";
};
FAD3DD42177221B500B0735B = {
isa = PBXGroup;
children = (
FA1792C7177843650092B567 /* MapsWithMe API */,
FAD3DD54177221B500B0735B /* Capitals */,
FAD3DD4D177221B500B0735B /* Frameworks */,
FAD3DD4C177221B500B0735B /* Products */,
);
sourceTree = "<group>";
};
FAD3DD4C177221B500B0735B /* Products */ = {
isa = PBXGroup;
children = (
FAD3DD4B177221B500B0735B /* Capitals.app */,
);
name = Products;
sourceTree = "<group>";
};
FAD3DD4D177221B500B0735B /* Frameworks */ = {
isa = PBXGroup;
children = (
FAD3DD4E177221B500B0735B /* UIKit.framework */,
FAD3DD50177221B500B0735B /* Foundation.framework */,
FAD3DD52177221B500B0735B /* CoreGraphics.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
FAD3DD54177221B500B0735B /* Capitals */ = {
isa = PBXGroup;
children = (
FAD3DD5D177221B500B0735B /* AppDelegate.h */,
FAD3DD5E177221B500B0735B /* AppDelegate.m */,
FAD3DD7D177223BB00B0735B /* City.h */,
FAD3DD7E1772246600B0735B /* City.m */,
FAD3DD8017724D4A00B0735B /* CityDetailViewController.h */,
FAD3DD8117724D4A00B0735B /* CityDetailViewController.m */,
FAD3DD8217724D4A00B0735B /* CityDetailViewController.xib */,
FAD3DD66177221B500B0735B /* MasterViewController.h */,
FAD3DD67177221B500B0735B /* MasterViewController.m */,
FA776B4D17848A370023F7A0 /* MasterViewController.xib */,
FAD3DD55177221B500B0735B /* Supporting Files */,
);
path = Capitals;
sourceTree = "<group>";
};
FAD3DD55177221B500B0735B /* Supporting Files */ = {
isa = PBXGroup;
children = (
FAA484E2178108970027B232 /* 114x114.png */,
FAA484E3178108970027B232 /* 144x144.png */,
FAA484E4178108970027B232 /* 100x100.png */,
FAA484E5178108970027B232 /* 72x72.png */,
FAA484E6178108970027B232 /* 58x58.png */,
FAA484E7178108970027B232 /* 57x57.png */,
FAA484E8178108970027B232 /* 50x50.png */,
FAA484E9178108970027B232 /* 29x29.png */,
FAD3DD56177221B500B0735B /* Capitals-Info.plist */,
FAD3DD5A177221B500B0735B /* main.m */,
FAD3DD5C177221B500B0735B /* Capitals-Prefix.pch */,
FAD3DD60177221B500B0735B /* Default.png */,
FAD3DD62177221B500B0735B /* Default@2x.png */,
FAD3DD64177221B500B0735B /* Default-568h@2x.png */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
FAD3DD4A177221B500B0735B /* Capitals */ = {
isa = PBXNativeTarget;
buildConfigurationList = FAD3DD7A177221B500B0735B /* Build configuration list for PBXNativeTarget "Capitals" */;
buildPhases = (
FAD3DD47177221B500B0735B /* Sources */,
FAD3DD48177221B500B0735B /* Frameworks */,
FAD3DD49177221B500B0735B /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Capitals;
productName = Capitals;
productReference = FAD3DD4B177221B500B0735B /* Capitals.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
FAD3DD43177221B500B0735B /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0460;
ORGANIZATIONNAME = "MapsWithMe GmbH";
};
buildConfigurationList = FAD3DD46177221B500B0735B /* Build configuration list for PBXProject "Capitals" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = FAD3DD42177221B500B0735B;
productRefGroup = FAD3DD4C177221B500B0735B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
FAD3DD4A177221B500B0735B /* Capitals */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
FAD3DD49177221B500B0735B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FAD3DD61177221B500B0735B /* Default.png in Resources */,
FAD3DD63177221B500B0735B /* Default@2x.png in Resources */,
FAD3DD65177221B500B0735B /* Default-568h@2x.png in Resources */,
FAD3DD8417724D4A00B0735B /* CityDetailViewController.xib in Resources */,
FAA484EA178108970027B232 /* 114x114.png in Resources */,
FAA484EB178108970027B232 /* 144x144.png in Resources */,
FAA484EC178108970027B232 /* 100x100.png in Resources */,
FAA484ED178108970027B232 /* 72x72.png in Resources */,
FAA484EE178108970027B232 /* 58x58.png in Resources */,
FAA484EF178108970027B232 /* 57x57.png in Resources */,
FAA484F0178108970027B232 /* 50x50.png in Resources */,
FAA484F1178108970027B232 /* 29x29.png in Resources */,
FA776B4F17848A370023F7A0 /* MasterViewController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
FAD3DD47177221B500B0735B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FAD3DD5B177221B500B0735B /* main.m in Sources */,
FAD3DD5F177221B500B0735B /* AppDelegate.m in Sources */,
FAD3DD68177221B500B0735B /* MasterViewController.m in Sources */,
FAD3DD7F1772246600B0735B /* City.m in Sources */,
FAD3DD8317724D4A00B0735B /* CityDetailViewController.m in Sources */,
FA1792CE17784F000092B567 /* MapsWithMeAPI.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
FA776B5117848EC50023F7A0 /* Production */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LIBRARY = "libstdc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
COPY_PHASE_STRIP = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PRODUCT_NAME = "Capitals of the World";
PROVISIONING_PROFILE = "";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Production;
};
FA776B5217848EC50023F7A0 /* Production */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Capitals/Capitals-Prefix.pch";
INFOPLIST_FILE = "Capitals/Capitals-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Production;
};
FAD3DD78177221B500B0735B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LIBRARY = "libstdc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "Capitals of the World";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
FAD3DD79177221B500B0735B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LIBRARY = "libstdc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PRODUCT_NAME = "Capitals of the World";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
FAD3DD7B177221B500B0735B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Capitals/Capitals-Prefix.pch";
INFOPLIST_FILE = "Capitals/Capitals-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
FAD3DD7C177221B500B0735B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Capitals/Capitals-Prefix.pch";
INFOPLIST_FILE = "Capitals/Capitals-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
FAD3DD46177221B500B0735B /* Build configuration list for PBXProject "Capitals" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FAD3DD78177221B500B0735B /* Debug */,
FAD3DD79177221B500B0735B /* Release */,
FA776B5117848EC50023F7A0 /* Production */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
FAD3DD7A177221B500B0735B /* Build configuration list for PBXNativeTarget "Capitals" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FAD3DD7B177221B500B0735B /* Debug */,
FAD3DD7C177221B500B0735B /* Release */,
FA776B5217848EC50023F7A0 /* Production */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = FAD3DD43177221B500B0735B /* Project object */;
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Capitals.xcodeproj">
</FileRef>
</Workspace>

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

View file

@ -26,38 +26,14 @@
******************************************************************************/
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_4_3
#error "MapsWithMe supports iOS >= 4.3 only"
#endif
@interface AppDelegate : UIResponder <UIApplicationDelegate>
// Wrapper for a pin on a map
@interface MWMPin : NSObject
@property (strong, nonatomic) UIWindow * window;
// [required] pin latitude and longitude
@property (nonatomic, assign) double lat;
@property (nonatomic, assign) double lon;
// [optional] pin title
@property (nonatomic, retain) NSString * optionalTitle;
// [optional] passed back to the app when pin is clicked, OR, if it's a valid url,
// it will be opened from MapsWithMe after selecting "More Details..." for the pin
@property (nonatomic, retain) NSString * optionalId;
- (id) initWithLat:(double)lat lon:(double)lon title:(NSString *)title id:(NSString *)pinId;
@end
@property (strong, nonatomic) UINavigationController * navigationController;
// MapsWithMe API interface
@interface MWMApi : NSObject
// returns YES if url is received from MapsWithMe and can be parsed
+ (BOOL) isMapsWithMeUrl:(NSURL *)url;
// returns nil if received url is invalid or not from MapsWithMe
+ (MWMPin *) pinFromUrl:(NSURL *)url;
// returns NO if MapsWithMe is not installed or outdated version doesn't support API calls
+ (BOOL) isApiSupported;
+ (BOOL) showLat:(double)lat lon:(double)lon title:(NSString *)optionalTitle id:(NSString *)optionalId;
+ (BOOL) showPin:(MWMPin *)pin;
+ (BOOL) showPins:(NSArray *)pins;
@property (strong, nonatomic) UISplitViewController * splitViewController;
@end

View file

@ -0,0 +1,107 @@
/*******************************************************************************
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#import "AppDelegate.h"
#import "MasterViewController.h"
#import "CityDetailViewController.h"
#import "MapsWithMeAPI.h"
@implementation AppDelegate
// MapsWithMe API entry point, when user comes back to your app
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([MWMApi isMapsWithMeUrl:url])
{
// if we got nil, it means that Back button was pressed without selecting any pin
MWMPin * pin = [MWMApi pinFromUrl:url];
if (pin)
{
size_t const cityId = [pin.optionalId integerValue];
// display selected page based on passed id
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
[self.navigationController popToRootViewControllerAnimated:NO];
MasterViewController * masterVC = [self.navigationController.viewControllers objectAtIndex:0];
if (!masterVC.detailViewController)
masterVC.detailViewController = [[[CityDetailViewController alloc] initWithNibName:@"CityDetailViewController" bundle:nil] autorelease];
masterVC.detailViewController.cityIndex = cityId;
[masterVC.navigationController pushViewController:masterVC.detailViewController animated:YES];
}
else
{
CityDetailViewController * detailVC = (CityDetailViewController *)self.splitViewController.delegate;
detailVC.cityIndex = cityId;
}
}
return YES;
}
return NO;
}
- (void)dealloc
{
self.window = nil;
self.navigationController = nil;
self.splitViewController = nil;
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
MasterViewController * masterViewController = [[[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil] autorelease];
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
self.window.rootViewController = self.navigationController;
}
else
{
MasterViewController * masterViewController = [[[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil] autorelease];
UINavigationController * masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
CityDetailViewController * detailViewController = [[[CityDetailViewController alloc] initWithNibName:@"CityDetailViewController" bundle:nil] autorelease];
UINavigationController * detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
masterViewController.detailViewController = detailViewController;
self.splitViewController = [[[UISplitViewController alloc] init] autorelease];
self.splitViewController.delegate = detailViewController;
self.splitViewController.viewControllers = @[masterNavigationController, detailNavigationController];
self.window.rootViewController = self.splitViewController;
}
[self.window makeKeyAndVisible];
return YES;
}
@end

View file

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFiles</key>
<array>
<string>114x114.png</string>
<string>144x144.png</string>
<string>100x100.png</string>
<string>72x72.png</string>
<string>58x58.png</string>
<string>57x57.png</string>
<string>50x50.png</string>
<string>29x29.png</string>
</array>
<key>CFBundleIdentifier</key>
<string>com.mapswithme.api.example.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>com.mapswithme.maps</string>
<key>CFBundleURLSchemes</key>
<array>
<string>MapsWithMeApiExampleCapitals</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIPrerenderedIcon</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIStatusBarTintParameters</key>
<dict>
<key>UINavigationBar</key>
<dict>
<key>Style</key>
<string>UIBarStyleDefault</string>
<key>Translucent</key>
<false/>
</dict>
</dict>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View file

@ -0,0 +1,38 @@
/*******************************************************************************
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#import <Availability.h>
#ifndef __IPHONE_4_3
#warning "This project uses features only available in iOS SDK 4.3 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

View file

@ -0,0 +1,41 @@
/*******************************************************************************
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
@class NSString;
typedef struct
{
NSString * name;
double lat;
double lon;
NSString * countryCode;
int population;
NSString * timeZone;
} City;
extern City const CAPITALS[241];

View file

@ -0,0 +1,272 @@
/*******************************************************************************
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#include "City.h"
City const CAPITALS[241] = {{@"Abu Dhabi", 24.46667, 54.36667, @"AE", 603492, @"Asia/Dubai"},
{@"Abuja", 9.06853, 7.48375, @"NG", 590400, @"Africa/Lagos"},
{@"Accra", 5.55602, -0.1969, @"GH", 1963264, @"Africa/Accra"},
{@"Adamstown", -25.06597, -130.1015, @"PN", 46, @"Pacific/Pitcairn"},
{@"Addis Ababa", 9.02497, 38.74689, @"ET", 2757729, @"Africa/Addis_Ababa"},
{@"Algiers", 36.7525, 3.04197, @"DZ", 1977663, @"Africa/Algiers"},
{@"Alofi", -19.05952, -169.9187, @"NU", 624, @"Pacific/Niue"},
{@"Amman", 31.95522, 35.94503, @"JO", 1275857, @"Asia/Amman"},
{@"Amsterdam", 52.37403, 4.88969, @"NL", 741636, @"Europe/Amsterdam"},
{@"Andorra la Vella", 42.50779, 1.52109, @"AD", 20430, @"Europe/Andorra"},
{@"Ankara", 39.91987, 32.85427, @"TR", 3517182, @"Europe/Istanbul"},
{@"Antananarivo", -18.91368, 47.53613, @"MG", 1391433, @"Indian/Antananarivo"},
{@"Apia", -13.83333, -171.7667, @"WS", 40407, @"Pacific/Apia"},
{@"Ashgabat", 37.95, 58.38333, @"TM", 727700, @"Asia/Ashgabat"},
{@"Asmara", 15.33805, 38.93184, @"ER", 563930, @"Africa/Asmara"},
{@"Astana", 51.1801, 71.44598, @"KZ", 345604, @"Asia/Almaty"},
{@"Asunción", -25.30066, -57.63591, @"PY", 1482200, @"America/Asuncion"},
{@"Athens", 37.97945, 23.71622, @"GR", 729137, @"Europe/Athens"},
{@"Avarua", -21.20778, -159.775, @"CK", 13373, @"Pacific/Rarotonga"},
{@"Baghdad", 33.34058, 44.40088, @"IQ", 5672513, @"Asia/Baghdad"},
{@"Baku", 40.37767, 49.89201, @"AZ", 1116513, @"Asia/Baku"},
{@"Bamako", 12.65, -8, @"ML", 1297281, @"Africa/Bamako"},
{@"Bandar Seri Begawan", 4.94029, 114.9481, @"BN", 64409, @"Asia/Brunei"},
{@"Bangkok", 13.75398, 100.5014, @"TH", 5104476, @"Asia/Bangkok"},
{@"Bangui", 4.36122, 18.55496, @"CF", 542393, @"Africa/Bangui"},
{@"Banjul", 13.45274, -16.57803, @"GM", 34589, @"Africa/Banjul"},
{@"Basse-Terre", 15.99854, -61.72548, @"GP", 11472, @"America/Guadeloupe"},
{@"Basseterre", 17.29484, -62.7261, @"KN", 12920, @"America/St_Kitts"},
{@"Beijing", 39.9075, 116.3972, @"CN", 7480601, @"Asia/Shanghai"},
{@"Beirut", 33.88894, 35.49442, @"LB", 1916100, @"Asia/Beirut"},
{@"Belgrade", 44.80401, 20.46513, @"RS", 1273651, @"Europe/Belgrade"},
{@"Belmopan", 17.25, -88.76667, @"BZ", 13381, @"America/Belize"},
{@"Berlin", 52.52437, 13.41053, @"DE", 3426354, @"Europe/Berlin"},
{@"Bern", 46.94809, 7.44744, @"CH", 121631, @"Europe/Zurich"},
{@"Bishkek", 42.87, 74.59, @"KG", 900000, @"Asia/Bishkek"},
{@"Bissau", 11.86357, -15.59767, @"GW", 388028, @"Africa/Bissau"},
{@"Bogotá", 4.60971, -74.08175, @"CO", 7102602, @"America/Bogota"},
{@"Brasília", -15.77972, -47.92972, @"BR", 2207718, @"America/Sao_Paulo"},
{@"Bratislava", 48.14816, 17.10674, @"SK", 423737, @"Europe/Bratislava"},
{@"Brazzaville", -4.26613, 15.28318, @"CG", 1284609, @"Africa/Brazzaville"},
{@"Bridgetown", 13.1, -59.61667, @"BB", 98511, @"America/Barbados"},
{@"Brussels", 50.85045, 4.34878, @"BE", 1019022, @"Europe/Brussels"},
{@"Bucharest", 44.43225, 26.10626, @"RO", 1877155, @"Europe/Bucharest"},
{@"Budapest", 47.49801, 19.03991, @"HU", 1696128, @"Europe/Budapest"},
{@"Buenos Aires", -34.61315, -58.37723, @"AR", 13076300, @"America/Argentina/Buenos_Aires"},
{@"Bujumbura", -3.3822, 29.3644, @"BI", 331700, @"Africa/Bujumbura"},
{@"Cairo", 30.06263, 31.24967, @"EG", 7734614, @"Africa/Cairo"},
{@"Canberra", -35.28346, 149.1281, @"AU", 327700, @"Australia/Sydney"},
{@"Caracas", 10.48801, -66.87919, @"VE", 3000000, @"America/Caracas"},
{@"Castries", 13.9957, -61.00614, @"LC", 10000, @"America/St_Lucia"},
{@"Cayenne", 4.93333, -52.33333, @"GF", 61550, @"America/Cayenne"},
{@"Charlotte Amalie", 18.3419, -64.9307, @"VI", 20000, @"America/St_Thomas"},
{@"Chişinău", 47.00556, 28.8575, @"MD", 635994, @"Europe/Chisinau"},
{@"Cockburn Town", 21.46122, -71.14188, @"TC", 3720, @"America/Grand_Turk"},
{@"Colombo", 6.93194, 79.84778, @"LK", 648034, @"Asia/Colombo"},
{@"Conakry", 9.53795, -13.67729, @"GN", 1767200, @"Africa/Conakry"},
{@"Copenhagen", 55.67594, 12.56553, @"DK", 1153615, @"Europe/Copenhagen"},
{@"Dakar", 14.6937, -17.44406, @"SN", 2476400, @"Africa/Dakar"},
{@"Damascus", 33.5102, 36.29128, @"SY", 1569394, @"Asia/Damascus"},
{@"Dhaka", 23.7104, 90.40744, @"BD", 10356500, @"Asia/Dhaka"},
{@"Dili", -8.55861, 125.5736, @"TL", 150000, @"Asia/Dili"},
{@"Djibouti", 11.58901, 43.14503, @"DJ", 623891, @"Africa/Djibouti"},
{@"Dodoma", -6.17221, 35.73947, @"TZ", 180541, @"Africa/Dar_es_Salaam"},
{@"Doha", 25.27932, 51.52245, @"QA", 344939, @"Asia/Qatar"},
{@"Douglas", 54.15, -4.48333, @"IM", 26218, @"Europe/Isle_of_Man"},
{@"Dublin", 53.33306, -6.24889, @"IE", 1024027, @"Europe/Dublin"},
{@"Dushanbe", 38.53575, 68.77905, @"TJ", 543107, @"Asia/Dushanbe"},
{@"Flying Fish Cove", -10.42172, 105.6791, @"CX", 500, @"Indian/Christmas"},
{@"Fort-de-France", 14.60892, -61.07334, @"MQ", 89995, @"America/Martinique"},
{@"Freetown", 8.484, -13.22994, @"SL", 802639, @"Africa/Freetown"},
{@"Funafuti", -8.52425, 179.1942, @"TV", 4492, @"Pacific/Funafuti"},
{@"Gaborone", -24.65451, 25.90859, @"BW", 208411, @"Africa/Gaborone"},
{@"George Town", 19.28692, -81.36706, @"KY", 29370, @"America/Cayman"},
{@"Georgetown", 6.80448, -58.15527, @"GY", 235017, @"America/Guyana"},
{@"Gibraltar", 36.14474, -5.35257, @"GI", 26544, @"Europe/Gibraltar"},
{@"Grytviken", -54.28111, -36.5092, @"GS", 2, @"Atlantic/South_Georgia"},
{@"Guatemala City", 14.64072, -90.51327, @"GT", 994938, @"America/Guatemala"},
{@"Gustavia", 17.89618, -62.84978, @"BL", 5988, @"America/St_Barthelemy"},
{@"Hagåtña", 13.47567, 144.7489, @"GU", 1051, @"Pacific/Guam"},
{@"Hamilton", 32.29149, -64.77797, @"BM", 902, @"Atlantic/Bermuda"},
{@"Harare", -17.82772, 31.05337, @"ZW", 1542813, @"Africa/Harare"},
{@"Havana", 23.13302, -82.38304, @"CU", 2163824, @"America/Havana"},
{@"Helsinki", 60.16952, 24.93545, @"FI", 558457, @"Europe/Helsinki"},
{@"Hong Kong", 22.28552, 114.1577, @"HK", 7012738, @"Asia/Hong_Kong"},
{@"Honiara", -9.43333, 159.95, @"SB", 56298, @"Pacific/Guadalcanal"},
{@"Hà Nội", 21.0245, 105.8412, @"VN", 1431270, @"Asia/Ho_Chi_Minh"},
{@"Islamabad", 33.72148, 73.04329, @"PK", 601600, @"Asia/Karachi"},
{@"Jakarta", -6.21462, 106.8451, @"ID", 8540121, @"Asia/Jakarta"},
{@"Jamestown", -15.93872, -5.71675, @"SH", 637, @"Atlantic/St_Helena"},
{@"Juba", 4.85165, 31.58247, @"SS", 300000, @"Africa/Juba"},
{@"Kabul", 34.52813, 69.17233, @"AF", 3043532, @"Asia/Kabul"},
{@"Kampala", 0.31628, 32.58219, @"UG", 1353189, @"Africa/Kampala"},
{@"Kathmandu", 27.70169, 85.3206, @"NP", 1442271, @"Asia/Kathmandu"},
{@"Khartoum", 15.55177, 32.53241, @"SD", 1974647, @"Africa/Khartoum"},
{@"Kiev", 50.45466, 30.5238, @"UA", 2514227, @"Europe/Kiev"},
{@"Kigali", -1.94995, 30.05885, @"RW", 745261, @"Africa/Kigali"},
{@"Kingston", -29.05459, 167.9663, @"NF", 880, @"Pacific/Norfolk"},
{@"Kingston", 17.99702, -76.79358, @"JM", 937700, @"America/Jamaica"},
{@"Kingstown", 13.15872, -61.22475, @"VC", 24518, @"America/St_Vincent"},
{@"Kinshasa", -4.32142, 15.30807, @"CD", 7785965, @"Africa/Kinshasa"},
{@"Kralendijk", 12.15, -68.26667, @"BQ", 3081, @"America/Kralendijk"},
{@"Kuala Lumpur", 3.1412, 101.6865, @"MY", 1453975, @"Asia/Kuala_Lumpur"},
{@"Kuwait City", 29.36972, 47.97833, @"KW", 60064, @"Asia/Kuwait"},
{@"El Aaiún", 27.16224, -13.20315, @"EH", 188084, @"Africa/El_Aaiun"},
{@"Libreville", 0.39241, 9.45356, @"GA", 578156, @"Africa/Libreville"},
{@"Lilongwe", -13.96692, 33.78725, @"MW", 646750, @"Africa/Blantyre"},
{@"Lima", -12.04318, -77.02824, @"PE", 7737002, @"America/Lima"},
{@"Lisbon", 38.71667, -9.13333, @"PT", 517802, @"Europe/Lisbon"},
{@"Ljubljana", 46.05108, 14.50513, @"SI", 255115, @"Europe/Ljubljana"},
{@"Lomé", 6.13748, 1.21227, @"TG", 749700, @"Africa/Lome"},
{@"London", 51.50853, -0.12574, @"GB", 7556900, @"Europe/London"},
{@"Longyearbyen", 78.2186, 15.64007, @"SJ", 2060, @"Arctic/Longyearbyen"},
{@"Luanda", -8.83682, 13.23432, @"AO", 2776168, @"Africa/Luanda"},
{@"Lusaka", -15.40669, 28.28713, @"ZM", 1267440, @"Africa/Lusaka"},
{@"Luxembourg", 49.61167, 6.13, @"LU", 76684, @"Europe/Luxembourg"},
{@"Macau", 22.20056, 113.5461, @"MO", 520400, @"Asia/Macau"},
{@"Madrid", 40.4165, -3.70256, @"ES", 3255944, @"Europe/Madrid"},
{@"Majuro", 7.08971, 171.3803, @"MH", 25400, @"Pacific/Majuro"},
{@"Malabo", 3.75, 8.78333, @"GQ", 155963, @"Africa/Malabo"},
{@"Male", 4.1748, 73.50888, @"MV", 103693, @"Indian/Maldives"},
{@"Mamoudzou", -12.77944, 45.22722, @"YT", 54831, @"Indian/Mayotte"},
{@"Managua", 12.13282, -86.2504, @"NI", 973087, @"America/Managua"},
{@"Manama", 26.21536, 50.5832, @"BH", 147074, @"Asia/Bahrain"},
{@"Manila", 14.6042, 120.9822, @"PH", 10444527, @"Asia/Manila"},
{@"Maputo", -25.96553, 32.58322, @"MZ", 1191613, @"Africa/Maputo"},
{@"Mariehamn", 60.09726, 19.93481, @"AX", 10682, @"Europe/Mariehamn"},
{@"Marigot", 18.06667, -63.08333, @"MF", 5700, @"America/Marigot"},
{@"Maseru", -29.31667, 27.48333, @"LS", 118355, @"Africa/Maseru"},
{@"Mata-Utu", -13.28163, -176.1745, @"WF", 1200, @"Pacific/Wallis"},
{@"Mbabane", -26.31667, 31.13333, @"SZ", 76218, @"Africa/Mbabane"},
{@"Melekeok", 7.50043, 134.6235, @"PW", 0, @"Pacific/Palau"},
{@"Mexico City", 19.42847, -99.12766, @"MX", 12294193, @"America/Mexico_City"},
{@"Minsk", 53.9, 27.56667, @"BY", 1742124, @"Europe/Minsk"},
{@"Mogadishu", 2.03711, 45.34375, @"SO", 2587183, @"Africa/Mogadishu"},
{@"Monaco", 43.73333, 7.41667, @"MC", 32965, @"Europe/Monaco"},
{@"Monrovia", 6.30054, -10.7969, @"LR", 939524, @"Africa/Monrovia"},
{@"Montevideo", -34.83346, -56.16735, @"UY", 1270737, @"America/Montevideo"},
{@"Moroni", -11.70216, 43.25506, @"KM", 42872, @"Indian/Comoro"},
{@"Moscow", 55.75222, 37.61556, @"RU", 10381222, @"Europe/Moscow"},
{@"Muscat", 23.61387, 58.5922, @"OM", 797000, @"Asia/Muscat"},
{@"N'Djamena", 12.10672, 15.0444, @"TD", 721081, @"Africa/Ndjamena"},
{@"Nairobi", -1.28333, 36.81667, @"KE", 2750547, @"Africa/Nairobi"},
{@"Nassau", 25.05823, -77.34306, @"BS", 227940, @"America/Nassau"},
{@"Nay Pyi Taw", 19.745, 96.12972, @"MM", 925000, @"Asia/Rangoon"},
{@"New Delhi", 28.63576, 77.22445, @"IN", 317797, @"Asia/Kolkata"},
{@"Niamey", 13.51366, 2.1098, @"NE", 774235, @"Africa/Niamey"},
{@"Nicosia", 35.16667, 33.36667, @"CY", 200452, @"Asia/Nicosia"},
{@"Nouakchott", 18.08581, -15.9785, @"MR", 661400, @"Africa/Nouakchott"},
{@"Nouméa", -22.27631, 166.4572, @"NC", 93060, @"Pacific/Noumea"},
{@"Nukualofa", -21.13938, -175.2018, @"TO", 22400, @"Pacific/Tongatapu"},
{@"Nuuk", 64.18347, -51.72157, @"GL", 14798, @"America/Godthab"},
{@"Oranjestad", 12.52398, -70.02703, @"AW", 29998, @"America/Aruba"},
{@"Oslo", 59.91273, 10.74609, @"NO", 580000, @"Europe/Oslo"},
{@"Ottawa", 45.41117, -75.69812, @"CA", 812129, @"America/Toronto"},
{@"Ouagadougou", 12.36566, -1.53388, @"BF", 1086505, @"Africa/Ouagadougou"},
{@"Pago Pago", -14.27806, -170.7025, @"AS", 11500, @"Pacific/Pago_Pago"},
{@"Palikir - National Government Center", 6.92477, 158.1611, @"FM", 0, @"Pacific/Pohnpei"},
{@"Panamá", 8.9936, -79.51973, @"PA", 408168, @"America/Panama"},
{@"Papeete", -17.53333, -149.5667, @"PF", 26357, @"Pacific/Tahiti"},
{@"Paramaribo", 5.86638, -55.16682, @"SR", 223757, @"America/Paramaribo"},
{@"Paris", 48.85341, 2.3488, @"FR", 2138551, @"Europe/Paris"},
{@"Philipsburg", 18.026, -63.04582, @"SX", 1400, @"America/Lower_Princes"},
{@"Phnom Penh", 11.56245, 104.916, @"KH", 1573544, @"Asia/Phnom_Penh"},
{@"Plymouth", 16.70555, -62.21292, @"MS", 0, @"America/Montserrat"},
{@"Podgorica", 42.44111, 19.26361, @"ME", 136473, @"Europe/Podgorica"},
{@"Port Louis", -20.16194, 57.49889, @"MU", 155226, @"Indian/Mauritius"},
{@"Port Moresby", -9.44314, 147.1797, @"PG", 283733, @"Pacific/Port_Moresby"},
{@"Port-Vila", -17.73381, 168.3219, @"VU", 35901, @"Pacific/Efate"},
{@"Port-au-Prince", 18.53917, -72.335, @"HT", 1234742, @"America/Port-au-Prince"},
{@"Port-aux-Français", -49.35, 70.21667, @"TF", 45, @"Indian/Kerguelen"},
{@"Port-of-Spain", 10.66617, -61.51657, @"TT", 49031, @"America/Port_of_Spain"},
{@"Porto-Novo", 6.49646, 2.60359, @"BJ", 234168, @"Africa/Porto-Novo"},
{@"Prague", 50.08804, 14.42076, @"CZ", 1165581, @"Europe/Prague"},
{@"Praia", 14.93152, -23.51254, @"CV", 113364, @"Atlantic/Cape_Verde"},
{@"Pretoria", -25.74486, 28.18783, @"ZA", 1619438, @"Africa/Johannesburg"},
{@"Pristina", 42.67272, 21.16688, @"XK", 550000, @"Europe/Belgrade"},
{@"Pyongyang", 39.03385, 125.7543, @"KP", 3222000, @"Asia/Pyongyang"},
{@"Quito", -0.22985, -78.52495, @"EC", 1399814, @"America/Guayaquil"},
{@"Rabat", 34.01325, -6.83255, @"MA", 1655753, @"Africa/Casablanca"},
{@"Reykjavík", 64.13548, -21.89541, @"IS", 113906, @"Atlantic/Reykjavik"},
{@"Riga", 56.946, 24.10589, @"LV", 742572, @"Europe/Riga"},
{@"Riyadh", 24.68773, 46.72185, @"SA", 4205961, @"Asia/Riyadh"},
{@"Road Town", 18.41667, -64.61667, @"VG", 8449, @"America/Tortola"},
{@"Rome", 41.89474, 12.4839, @"IT", 2563241, @"Europe/Rome"},
{@"Roseau", 15.30174, -61.38808, @"DM", 16571, @"America/Dominica"},
{@"Saint George's", 12.05644, -61.74849, @"GD", 7500, @"America/Grenada"},
{@"Saint Helier", 49.18804, -2.10491, @"JE", 28000, @"Europe/Jersey"},
{@"Saint Johns", 17.11667, -61.85, @"AG", 24226, @"America/Antigua"},
{@"Saint Peter Port", 49.45981, -2.53527, @"GG", 16488, @"Europe/Guernsey"},
{@"Saint-Denis", -20.88231, 55.4504, @"RE", 137195, @"Indian/Reunion"},
{@"Saint-Pierre", 46.78091, -56.17196, @"PM", 6200, @"America/Miquelon"},
{@"Saipan", 15.21233, 145.7545, @"MP", 48220, @"Pacific/Saipan"},
{@"San José", 9.93333, -84.08333, @"CR", 335007, @"America/Costa_Rica"},
{@"San Juan", 18.46633, -66.10572, @"PR", 418140, @"America/Puerto_Rico"},
{@"San Marino", 43.93667, 12.44639, @"SM", 4500, @"Europe/San_Marino"},
{@"San Salvador", 13.68935, -89.18718, @"SV", 525990, @"America/El_Salvador"},
{@"Sanaa", 15.35472, 44.20667, @"YE", 1937451, @"Asia/Aden"},
{@"Santiago", -33.45694, -70.64827, @"CL", 4837295, @"America/Santiago"},
{@"Santo Domingo", 18.50012, -69.98857, @"DO", 2201941, @"America/Santo_Domingo"},
{@"Sarajevo", 43.84864, 18.35644, @"BA", 696731, @"Europe/Sarajevo"},
{@"Seoul", 37.56826, 126.9778, @"KR", 10349312, @"Asia/Seoul"},
{@"Singapore", 1.28967, 103.8501, @"SG", 3547809, @"Asia/Singapore"},
{@"Skopje", 42.00122, 21.42878, @"MK", 474889, @"Europe/Skopje"},
{@"Sofia", 42.69751, 23.32415, @"BG", 1152556, @"Europe/Sofia"},
{@"Stanley", -51.7, -57.85, @"FK", 2213, @"Atlantic/Stanley"},
{@"Stockholm", 59.33258, 18.0649, @"SE", 1253309, @"Europe/Stockholm"},
{@"Sucre", -19.03332, -65.26274, @"BO", 224838, @"America/La_Paz"},
{@"Suva", -18.14161, 178.4415, @"FJ", 77366, @"Pacific/Fiji"},
{@"São Tomé", 0.33654, 6.72732, @"ST", 53300, @"Africa/Sao_Tome"},
{@"Taipei", 25.04776, 121.5319, @"TW", 7871900, @"Asia/Taipei"},
{@"Tallinn", 59.43696, 24.75353, @"EE", 394024, @"Europe/Tallinn"},
{@"Tarawa", 1.3278, 172.977, @"KI", 40311, @"Pacific/Tarawa"},
{@"Tashkent", 41.26465, 69.21627, @"UZ", 1978028, @"Asia/Tashkent"},
{@"Tbilisi", 41.69411, 44.83368, @"GE", 1049498, @"Asia/Tbilisi"},
{@"Tegucigalpa", 14.0818, -87.20681, @"HN", 850848, @"America/Tegucigalpa"},
{@"Tehrān", 35.69439, 51.42151, @"IR", 7153309, @"Asia/Tehran"},
{@"The Valley", 18.21704, -63.05783, @"AI", 2035, @"America/Anguilla"},
{@"Thimphu", 27.46609, 89.64191, @"BT", 98676, @"Asia/Thimphu"},
{@"Tirana", 41.3275, 19.81889, @"AL", 374801, @"Europe/Tirane"},
{@"Tokyo", 35.6895, 139.6917, @"JP", 8336599, @"Asia/Tokyo"},
{@"Tripoli", 32.87519, 13.18746, @"LY", 1150989, @"Africa/Tripoli"},
{@"Tunis", 36.81897, 10.16579, @"TN", 693210, @"Africa/Tunis"},
{@"Tórshavn", 62.00973, -6.77164, @"FO", 13200, @"Atlantic/Faroe"},
{@"Ulaanbaatar", 47.90771, 106.8832, @"MN", 844818, @"Asia/Ulaanbaatar"},
{@"Vaduz", 47.14151, 9.52154, @"LI", 5197, @"Europe/Vaduz"},
{@"Valletta", 35.89972, 14.51472, @"MT", 6794, @"Europe/Malta"},
{@"Vatican City", 41.90236, 12.45332, @"VA", 829, @"Europe/Vatican"},
{@"Victoria", -4.61667, 55.45, @"SC", 22881, @"Indian/Mahe"},
{@"Vienna", 48.20849, 16.37208, @"AT", 1691468, @"Europe/Vienna"},
{@"Vientiane", 17.96667, 102.6, @"LA", 196731, @"Asia/Vientiane"},
{@"Vilnius", 54.68916, 25.2798, @"LT", 542366, @"Europe/Vilnius"},
{@"Warsaw", 52.22977, 21.01178, @"PL", 1702139, @"Europe/Warsaw"},
{@"Washington, D. C.", 38.89511, -77.03637, @"US", 601723, @"America/New_York"},
{@"Wellington", -41.28664, 174.7756, @"NZ", 381900, @"Pacific/Auckland"},
{@"West Island", -12.15681, 96.82251, @"CC", 120, @"Indian/Cocos"},
{@"Willemstad", 12.1084, -68.93354, @"CW", 125000, @"America/Curacao"},
{@"Windhoek", -22.55941, 17.08323, @"NA", 268132, @"Africa/Windhoek"},
{@"Yamoussoukro", 6.82055, -5.27674, @"CI", 194530, @"Africa/Abidjan"},
{@"Yaoundé", 3.86667, 11.51667, @"CM", 1299369, @"Africa/Douala"},
{@"Yerevan", 40.18111, 44.51361, @"AM", 1093485, @"Asia/Yerevan"},
{@"Zagreb", 45.81444, 15.97798, @"HR", 698966, @"Europe/Zagreb"}
};

View file

@ -0,0 +1,35 @@
/*******************************************************************************
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#import <UIKit/UIKit.h>
@interface CityDetailViewController : UITableViewController <UISplitViewControllerDelegate>
@property (nonatomic, assign) size_t cityIndex;
@end

View file

@ -0,0 +1,175 @@
/*******************************************************************************
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#import "CityDetailViewController.h"
#import "City.h"
#import "MapsWithMeAPI.h"
@interface CityDetailViewController ()
@property (strong, nonatomic) UIPopoverController * masterPopoverController;
- (void)configureView;
@end
@implementation CityDetailViewController
- (NSString *)urlEncode:(NSString *)str
{
return [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)str, NULL, CFSTR("!$&'()*+,-./:;=?@_~"), kCFStringEncodingUTF8) autorelease];
}
- (void)showCapitalOnTheMap:(BOOL)withLink
{
City const * city = &CAPITALS[_cityIndex];
NSString * pinId;
if (withLink)
pinId = [NSString stringWithFormat:@"http://en.wikipedia.org/wiki/%@", [self urlEncode:city->name]];
else
pinId = [NSString stringWithFormat:@"%ld", _cityIndex];
[MWMApi showLat:city->lat lon:city->lon title:city->name id:pinId];
}
- (void)dealloc
{
self.masterPopoverController = nil;
[super dealloc];
}
- (void)setCityIndex:(size_t)newCityIndex
{
if (_cityIndex != newCityIndex)
{
_cityIndex = newCityIndex;
// Update the view.
[self configureView];
}
if (self.masterPopoverController != nil)
[self.masterPopoverController dismissPopoverAnimated:YES];
}
- (void)configureView
{
self.title = CAPITALS[_cityIndex].name;
[self.tableView reloadData];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self configureView];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return section == 0 ? 5 : 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString * cellId = [NSString stringWithFormat:@"%d%d", indexPath.section, indexPath.row];
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if (cell == nil)
{
if (indexPath.section == 0)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
switch (indexPath.row)
{
case 0: cell.textLabel.text = @"Latitude"; break;
case 1: cell.textLabel.text = @"Longitude"; break;
case 2: cell.textLabel.text = @"Country Code"; break;
case 3: cell.textLabel.text = @"Population"; break;
case 4: cell.textLabel.text = @"Time Zone"; break;
default: break;
}
}
else
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId] autorelease];
cell.textLabel.textAlignment = UITextAlignmentCenter;
if (indexPath.section == 1)
cell.textLabel.text = @"Show map and come back";
else
cell.textLabel.text = @"Show map and read Wikipedia";
}
}
if (indexPath.section == 0)
{
City const * city = &CAPITALS[_cityIndex];
switch (indexPath.row)
{
case 0: cell.detailTextLabel.text = [NSString stringWithFormat:@"%lf", city->lat]; break;
case 1: cell.detailTextLabel.text = [NSString stringWithFormat:@"%lf", city->lon]; break;
case 2: cell.detailTextLabel.text = city->countryCode; break;
case 3: cell.detailTextLabel.text = [NSString stringWithFormat:@"%d", city->population]; break;
case 4: cell.detailTextLabel.text = city->timeZone; break;
default: break;
}
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
switch (indexPath.section)
{
case 1: [self showCapitalOnTheMap:NO]; break;
case 2: [self showCapitalOnTheMap:YES]; break;
default: break;
}
}
#pragma mark - Split view
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
barButtonItem.title = NSLocalizedString(@"World Capitals", nil);
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
self.masterPopoverController = popoverController;
}
- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
// Called when the view is shown again in the split view, invalidating the button and popover controller.
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
self.masterPopoverController = nil;
}
@end

View file

@ -0,0 +1,164 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1552</int>
<string key="IBDocument.SystemVersion">12E55</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.39</string>
<string key="IBDocument.HIToolboxVersion">626.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">2083</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
<string>IBUITableView</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</array>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="IBProxyObject" id="372490531">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
<object class="IBProxyObject" id="975951072">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
<object class="IBUITableView" id="993928743">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<string key="NSFrameSize">{768, 1024}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MCAwIDAgMAA</bytes>
<string key="IBUIColorCocoaTouchKeyPath">groupTableViewBackgroundColor</string>
</object>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<object class="IBUISimulatedSizeMetrics" key="IBUISimulatedDestinationMetrics">
<string key="IBUISimulatedSizeMetricsClass">IBUISplitViewDetailSimulatedSizeMetrics</string>
<object class="NSMutableDictionary" key="IBUINormalizedOrientationToSizeMap">
<bool key="EncodedWithXMLCoder">YES</bool>
<array key="dict.sortedKeys">
<integer value="1"/>
<integer value="3"/>
</array>
<array key="dict.values">
<string>{768, 1024}</string>
<string>{703, 768}</string>
</array>
</object>
<string key="IBUITargetRuntime">IBIPadFramework</string>
<string key="IBUIDisplayName">Detail</string>
<string key="IBUIDestinationClass">IBUISplitViewController</string>
<object class="NSDictionary" key="IBUIDestinationContext">
<string key="NS.key.0">IBUISplitViewControllerContentSizeLocation</string>
<string key="NS.object.0">IBUISplitViewControllerContentSizeLocationDetail</string>
</object>
</object>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<bool key="IBUIBouncesZoom">NO</bool>
<int key="IBUIStyle">1</int>
<int key="IBUISeparatorStyle">2</int>
<int key="IBUISectionIndexMinimumDisplayRowCount">0</int>
<bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool>
<float key="IBUIRowHeight">44</float>
<float key="IBUISectionHeaderHeight">10</float>
<float key="IBUISectionFooterHeight">10</float>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="993928743"/>
</object>
<int key="connectionID">11</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">dataSource</string>
<reference key="source" ref="993928743"/>
<reference key="destination" ref="372490531"/>
</object>
<int key="connectionID">9</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="993928743"/>
<reference key="destination" ref="372490531"/>
</object>
<int key="connectionID">10</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
<object class="IBObjectRecord">
<int key="objectID">0</int>
<array key="object" id="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="372490531"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="975951072"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="993928743"/>
<reference key="parent" ref="0"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.CustomClassName">CityDetailViewController</string>
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="-2.CustomClassName">UIResponder</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="8.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">11</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">CityDetailViewController</string>
<string key="superclassName">UITableViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/CityDetailViewController.h</string>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBIPadFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<bool key="IBDocument.UseAutolayout">YES</bool>
<string key="IBCocoaTouchPluginVersion">2083</string>
</data>
</archive>

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 KiB

View file

@ -0,0 +1,37 @@
/*******************************************************************************
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#import <UIKit/UIKit.h>
@class CityDetailViewController;
@interface MasterViewController : UITableViewController
@property (strong, nonatomic) CityDetailViewController * detailViewController;
@end

View file

@ -0,0 +1,140 @@
/*******************************************************************************
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#import "MasterViewController.h"
#import "CityDetailViewController.h"
#import "City.h"
#import "MapsWithMeAPI.h"
@implementation MasterViewController
- (void)showAllCitiesOnTheMap:(id)sender
{
size_t const capitalsCount = sizeof(CAPITALS)/sizeof(CAPITALS[0]);
NSMutableArray * array = [[NSMutableArray alloc] initWithCapacity:capitalsCount];
for (size_t i = 0; i < capitalsCount; ++i)
{
NSString * pinId = [[[NSString alloc] initWithFormat:@"%ld", i] autorelease];
// Note that url is empty - it means "More details" button for a pin in MapsWithMe will lead back to this example app
MWMPin * pin = [[[MWMPin alloc] initWithLat:CAPITALS[i].lat lon:CAPITALS[i].lon title:CAPITALS[i].name id:pinId] autorelease];
[array addObject:pin];
}
[MWMApi showPins:array];
[array release];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
self.title = NSLocalizedString(@"World Capitals", nil);
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
{
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
}
}
return self;
}
- (void)dealloc
{
self.detailViewController = nil;
[super dealloc];
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem * showMapButton = [[[UIBarButtonItem alloc] initWithTitle:@"Show All" style:UIBarButtonItemStyleDone target:self action:@selector(showAllCitiesOnTheMap:)] autorelease];
self.navigationItem.rightBarButtonItem = showMapButton;
}
#pragma mark - Table View
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return sizeof(CAPITALS)/sizeof(CAPITALS[0]);
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UILabel * label = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 240, tableView.rowHeight)] autorelease];
label.text = [MWMApi isApiSupported] ? @"MapsWithMe is installed" : @"MapsWithMe is not installed";
label.textAlignment = UITextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
return label;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return tableView.rowHeight / 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString * cellId = @"MasterCell";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId] autorelease];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.textLabel.text = CAPITALS[indexPath.row].name;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
self.detailViewController.cityIndex = indexPath.row;
else
{
if (!self.detailViewController)
self.detailViewController = [[[CityDetailViewController alloc] initWithNibName:@"CityDetailViewController" bundle:nil] autorelease];
self.detailViewController.cityIndex = indexPath.row;
[self.navigationController pushViewController:self.detailViewController animated:YES];
}
}
@end

View file

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1552</int>
<string key="IBDocument.SystemVersion">12E55</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.39</string>
<string key="IBDocument.HIToolboxVersion">626.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">2083</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
<string>IBUITableView</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</array>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="IBProxyObject" id="841351856">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBProxyObject" id="371349661">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUITableView" id="709618507">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<string key="NSFrame">{{0, 20}, {320, 548}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MCAwIDAgMAA</bytes>
<string key="IBUIColorCocoaTouchKeyPath">groupTableViewBackgroundColor</string>
</object>
<bool key="IBUIClipsSubviews">YES</bool>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
<object class="IBUIScreenMetrics" key="IBUISimulatedDestinationMetrics">
<string key="IBUISimulatedSizeMetricsClass">IBUIScreenMetrics</string>
<object class="NSMutableDictionary" key="IBUINormalizedOrientationToSizeMap">
<bool key="EncodedWithXMLCoder">YES</bool>
<array key="dict.sortedKeys">
<integer value="1"/>
<integer value="3"/>
</array>
<array key="dict.values">
<string>{320, 568}</string>
<string>{568, 320}</string>
</array>
</object>
<string key="IBUITargetRuntime">IBCocoaTouchFramework</string>
<string key="IBUIDisplayName">Retina 4 Full Screen</string>
<int key="IBUIType">2</int>
</object>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBUIAlwaysBounceVertical">YES</bool>
<int key="IBUIStyle">1</int>
<int key="IBUISeparatorStyle">2</int>
<int key="IBUISectionIndexMinimumDisplayRowCount">0</int>
<bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool>
<float key="IBUIRowHeight">44</float>
<float key="IBUISectionHeaderHeight">10</float>
<float key="IBUISectionFooterHeight">10</float>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="709618507"/>
</object>
<int key="connectionID">3</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">dataSource</string>
<reference key="source" ref="709618507"/>
<reference key="destination" ref="841351856"/>
</object>
<int key="connectionID">4</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="709618507"/>
<reference key="destination" ref="841351856"/>
</object>
<int key="connectionID">5</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
<object class="IBObjectRecord">
<int key="objectID">0</int>
<array key="object" id="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="841351856"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="371349661"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="709618507"/>
<reference key="parent" ref="0"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.CustomClassName">MasterViewController</string>
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="-2.CustomClassName">UIResponder</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">5</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">MasterViewController</string>
<string key="superclassName">UITableViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MasterViewController.h</string>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<bool key="IBDocument.UseAutolayout">YES</bool>
<string key="IBCocoaTouchPluginVersion">2083</string>
</data>
</archive>

View file

@ -0,0 +1,39 @@
/*******************************************************************************
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[])
{
@autoreleasepool
{
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}

View file

@ -1,248 +0,0 @@
/*******************************************************************************
Copyright (c) 2013, MapsWithMe GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#import "MapsWithMeAPI.h"
#define MAPSWITHME_API_VERSION 1
static NSString * MWMUrlScheme = @"mapswithme://";
@implementation MWMPin
- (id) init
{
if ((self = [super init]))
{
self.lat = INFINITY;
self.lon = INFINITY;
}
return self;
}
- (id) initWithLat:(double)lat lon:(double)lon title:(NSString *)title id:(NSString *)pinId
{
if ((self = [super init]))
{
self.lat = lat;
self.lon = lon;
self.optionalTitle = title;
self.optionalId = pinId;
}
return self;
}
- (void)dealloc
{
self.optionalTitle = nil;
self.optionalId = nil;
[super dealloc];
}
@end
// Utility class to automatically handle "MapsWithMe is not installed" situations
@interface MWMNavigationController : UINavigationController
@end
@implementation MWMNavigationController
- (void)onCloseButtonClicked:(id)sender
{
[self dismissModalViewControllerAnimated:YES];
}
@end
@implementation MWMApi
+ (BOOL) isMapsWithMeUrl:(NSURL *)url
{
NSString * appScheme = [MWMApi detectBackUrlScheme];
return appScheme && [url.scheme isEqualToString:appScheme];
}
+ (MWMPin *) pinFromUrl:(NSURL *)url
{
if (![MWMApi isMapsWithMeUrl:url])
return nil;
MWMPin * pin = nil;
if ([url.host isEqualToString:@"pin"])
{
pin = [[[MWMPin alloc] init] autorelease];
for (NSString * param in [url.query componentsSeparatedByString:@"&"])
{
NSArray * values = [param componentsSeparatedByString:@"="];
if (values.count == 2)
{
NSString * key = [values objectAtIndex:0];
if ([key isEqualToString:@"ll"])
{
NSArray * coords = [param componentsSeparatedByString:@","];
if (coords.count == 2)
{
pin.lat = [[NSDecimalNumber decimalNumberWithString:[coords objectAtIndex:0]] doubleValue];
pin.lon = [[NSDecimalNumber decimalNumberWithString:[coords objectAtIndex:1]] doubleValue];
}
}
else if ([key isEqualToString:@"n"])
pin.optionalTitle = [[values objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
else if ([key isEqualToString:@"id"])
pin.optionalId = [[values objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
else
NSLog(@"Unsupported url parameters: %@", values);
}
}
// do not accept invalid coordinates
if (pin.lat > 90. || pin.lat < -90. || pin.lon > 180. || pin.lon < -180.)
pin = nil;
}
return pin;
}
+ (BOOL) isApiSupported
{
return [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:MWMUrlScheme]];
}
+ (BOOL) showLat:(double)lat lon:(double)lon title:(NSString *)optionalTitle id:(NSString *)optionalId
{
MWMPin * pin = [[[MWMPin alloc] initWithLat:lat lon:lon title:optionalTitle id:optionalId] autorelease];
return [MWMApi showPin:pin];
}
+ (BOOL) showPin:(MWMPin *)pin
{
return [MWMApi showPins:[NSArray arrayWithObject:pin]];
}
+ (BOOL) showPins:(NSArray *)pins
{
// Automatic check that MapsWithMe is installed
if (![MWMApi isApiSupported])
{
// Display dialog with link to the app
[MWMApi showMapsWithMeIsNotInstalledDialog];
return NO;
}
NSString * appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
NSMutableString * str = [[NSMutableString alloc] initWithFormat:@"%@map?v=%d&appname=%@&", MWMUrlScheme, MAPSWITHME_API_VERSION,
[appName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString * backUrlScheme = [MWMApi detectBackUrlScheme];
if (backUrlScheme)
[str appendFormat:@"backurl=%@&", [backUrlScheme stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
for (MWMPin * point in pins)
{
[str appendFormat:@"ll=%f,%f&", point.lat, point.lon];
@autoreleasepool
{
if (point.optionalTitle)
[str appendFormat:@"n=%@&", [point.optionalTitle stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if (point.optionalId)
[str appendFormat:@"id=%@&", [point.optionalId stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
}
}
NSURL * url = [[NSURL alloc] initWithString:str];
[str release];
if (url)
{
[[UIApplication sharedApplication] openURL:url];
[url release];
return YES;
}
else
{
NSLog(@"Can't generate correct url");
return NO;
}
}
+ (NSString *) detectBackUrlScheme
{
for (NSDictionary * dict in [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"])
{
if ([[dict objectForKey:@"CFBundleURLName"] rangeOfString:@"mapswithme" options:NSCaseInsensitiveSearch].location != NSNotFound)
{
for (NSString * scheme in [dict objectForKey:@"CFBundleURLSchemes"])
{
if ([scheme rangeOfString:@"mapswithme" options:NSCaseInsensitiveSearch].location != NSNotFound)
return scheme;
}
}
}
NSLog(@"WARNING: No com.mapswithme.maps url schemes are added in the Info.plist file. Please add them if you want API users to come back to your app.");
return nil;
}
// HTML page for users who didn't install MapsWithMe
static NSString * mapsWithMeIsNotInstalledPage =
@"<html>" \
"<head>" \
"<title>Please install MapsWithMe - offline maps of the World</title>" \
"<meta name='viewport' content='width=device-width, initial-scale=1.0'/>" \
"<meta charset='UTF-8'/>" \
"<style type='text/css'>" \
"body { font-family: Roboto,Helvetica; background-color:#fafafa; text-align: center;}" \
".description { text-align: center; font-size: 0.85em; margin-bottom: 1em; }" \
".button { -moz-border-radius: 20px; -webkit-border-radius: 20px; -khtml-border-radius: 20px; border-radius: 20px; padding: 10px; text-decoration: none; display:inline-block; margin: 0.5em; }" \
".shadow { -moz-box-shadow: 3px 3px 5px 0 #444; -webkit-box-shadow: 3px 3px 5px 0 #444; box-shadow: 3px 3px 5px 0 #444; }" \
".lite { color: white; background-color: #333; }" \
".pro { color: white; background-color: green; }" \
".mwm { color: green; text-decoration: none; }" \
"</style>" \
"</head>" \
"<body>" \
"<div class='description'><a href='http://mapswith.me' target='_blank' class='mwm'>MapsWithMe</a> app should be installed to view the map.</div>" \
"<a href='http://mapswith.me/app?api' class='lite button shadow'>Download&nbsp;MapsWithMe&nbsp;Lite&nbsp;(free)</a>" \
"<a href='http://mapswith.me/get?api' class='pro button shadow'>Download&nbsp;MapsWithMe&nbsp;Pro</a>" \
"</body>" \
"</html>";
// For gethostbyname below
#include <netdb.h>
+ (void) showMapsWithMeIsNotInstalledDialog
{
UIWebView * webView = [[[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
// check that we have Internet connection and display fresh online page if possible
if (gethostbyname("google.com"))
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://mapswith.me/api_mwm_not_installed"]]];
else
[webView loadHTMLString:mapsWithMeIsNotInstalledPage baseURL:[NSURL URLWithString:@"http://mapswith.me/"]];
UIViewController * webController = [[[UIViewController alloc] init] autorelease];
webController.view = webView;
webController.title = @"Install MapsWithMe";
MWMNavigationController * navController = [[[MWMNavigationController alloc] initWithRootViewController:webController] autorelease];
navController.navigationBar.topItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleDone target:navController action:@selector(onCloseButtonClicked:)];
[[[UIApplication sharedApplication] delegate].window.rootViewController presentModalViewController:navController animated:YES];
}
@end