Commit fad4b5ab authored by Fabio Pelosin's avatar Fabio Pelosin

Merge branch 'master' into 0.17

* master:
  Release 0.16.2
  Bump Xcodeproj dependency.
  Update CHANGELOG
  Make specs green.
  Update bundle.
  Run on the new Travis CI mac workers on both system Ruby and 1.9.3-p327.
  Generate Pods target in Mac OS X with the specified deployment target.
  Disable libSystem objects for ARC libs that target older platforms.
  Fix podspec in Podfile with no options.
  Add install note for RVM users about symlinking GCC to LLVM-GCC.
  Removed comments from Mercurial sample podspec used in tests.
  Added support for pre-download over Mercurial.
  Quote storyboard and xib paths

Conflicts:
	CHANGELOG.md
	Gemfile.lock
	cocoapods.gemspec
	examples/AFNetworking Mac Example/Podfile.lock
	examples/AFNetworking iOS Example/Podfile.lock
	examples/MGSplitView/Podfile.lock
	examples/RKTwitter/Podfile.lock
	examples/RKTwitter/RKTwitter.xcodeproj/project.pbxproj
	examples/RelativePathProject/Podfile.lock
	examples/SSCatalog/Podfile.lock
	examples/SSCatalog/SSCatalog.xcodeproj/project.pbxproj
	examples/TargetTest/Podfile.lock
	lib/cocoapods.rb
	lib/cocoapods/dependency.rb
	lib/cocoapods/platform.rb
	lib/cocoapods/podfile.rb
	lib/cocoapods/project.rb
	lib/cocoapods/specification.rb
	spec/fixtures/mercurial-repo/.hg/dirstate
	spec/fixtures/mercurial-repo/.hg/last-message.txt
	spec/fixtures/mercurial-repo/.hg/store/00changelog.i
	spec/fixtures/mercurial-repo/.hg/store/00manifest.i
	spec/fixtures/mercurial-repo/.hg/store/fncache
	spec/fixtures/mercurial-repo/.hg/store/undo
	spec/fixtures/mercurial-repo/.hg/undo.desc
	spec/fixtures/mercurial-repo/.hg/undo.dirstate
	spec/integration_spec.rb
	spec/unit/dependency_spec.rb
	spec/unit/local_pod_spec.rb
	spec/unit/podfile_spec.rb
	spec/unit/specification_spec.rb
parents 3170668d 0be241d8
language: ruby language: objective-c
rvm: env:
- 1.8.7 # This is what 10.8.x comes with and we want to support that.
- 1.9.3 - RVM_RUBY_VERSION=system NOEXEC_DISABLE=1 RUBY_VERSION_SPECIFIC='sudo gem update --system && sudo gem install bundler --no-ri --no-rdoc'
# Not in Travis non-pro yet - RVM_RUBY_VERSION=1.9.3 NOEXEC_DISABLE=1 RUBY_VERSION_SPECIFIC='sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2 && curl http://curl.haxx.se/ca/cacert.pem -o /usr/local/share/cacert.pem' SSL_CERT_FILE=/usr/local/share/cacert.pem
#- 2.0.0 before_install: source ~/.rvm/scripts/rvm && rvm use $RVM_RUBY_VERSION
# Rubinius in 1.8 mode on Travis does not work. It complains about st_data_t etc in Xcodeproj. install: eval $RUBY_VERSION_SPECIFIC && rake bootstrap
#- rbx-18mode script: bundle exec rake spec:ci
- rbx-19mode
matrix:
allow_failures:
- rvm: rbx-19mode
#- rvm: 2.0.0
install: NOEXEC=skip rake travis:setup
script: bundle exec rake spec
notifications: notifications:
# email: false
campfire: campfire:
on_success: change on_success: change
on_failure: always on_failure: always
......
...@@ -68,6 +68,34 @@ ...@@ -68,6 +68,34 @@
- Added Library class. - Added Library class.
- Added XCConfig generator. - Added XCConfig generator.
## 0.16.2
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.16.1...0.16.2)[Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.4.1...0.4.3)
###### Bug fixes
- Quote storyboard and xib paths in ‘copy resource’ script.
[#740](https://github.com/CocoaPods/CocoaPods/pull/740)
- Fix use of `podspec` directive in Podfile with no options specified.
[#768](https://github.com/CocoaPods/CocoaPods/pull/768)
- Generate Mac OS X Pods target with the specified deployment target.
[#757](https://github.com/CocoaPods/CocoaPods/issues/757)
- Disable libSystem objects for ARC libs that target older platforms.
This applies when the deployment target is set to < iOS 6.0 or OS X 10.8,
or not specified at all.
[#352](https://github.com/CocoaPods/Specs/issues/352)
[#1161](https://github.com/CocoaPods/Specs/pull/1161)
- Mark header source files as ‘Project’ not ‘Public’.
[#747](https://github.com/CocoaPods/CocoaPods/issues/747)
- Add `PBXGroup` as acceptable `PBXFileReference` value.
[#49](https://github.com/CocoaPods/Xcodeproj/pull/49)
- Make `xcodeproj show` without further arguments actually work.
[#45](https://github.com/CocoaPods/Xcodeproj/issues/45)
###### Enhancements
- Added support for pre-download over Mercurial.
[#750](https://github.com/CocoaPods/CocoaPods/pull/750)
## 0.16.1 ## 0.16.1
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.16.0...0.16.1)[Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.4.0...0.4.1) [CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.16.0...0.16.1)[Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.4.0...0.4.1)
......
...@@ -45,6 +45,8 @@ Or from `Xcode > Settings > Downloads > Components > Command Line Tools` ...@@ -45,6 +45,8 @@ Or from `Xcode > Settings > Downloads > Components > Command Line Tools`
2. CocoaPods re-uses some of the RubyGems classes. If you have a version older than 1.4.0, you will have to update RubyGems: `$ gem update --system`. 2. CocoaPods re-uses some of the RubyGems classes. If you have a version older than 1.4.0, you will have to update RubyGems: `$ gem update --system`.
3. If you use [RVM](https://rvm.io), you might need to create a symbolic link to the LLVM GCC compiler: `$ [sudo] ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2`
## Adding it to your project ## Adding it to your project
......
# Travis support def execute_command(command)
def on_rvm? if ENV['VERBOSE']
`which ruby`.strip.include?('.rvm') sh(command)
end else
output = `#{command} 2>&1`
def rvm_ruby_dir raise output unless $?.success?
@rvm_ruby_dir ||= File.expand_path('../..', `which ruby`.strip)
end
namespace :travis do
# Used to create the deb package.
#
# Known to work with opencflite rev 248.
task :prepare_deb do
sh "sudo apt-get install subversion libicu-dev"
sh "svn co https://opencflite.svn.sourceforge.net/svnroot/opencflite/trunk opencflite"
sh "cd opencflite && ./configure --target=linux --with-uuid=/usr --with-tz-includes=./include --prefix=/usr/local && make && sudo make install"
sh "sudo /sbin/ldconfig"
end
task :install_opencflite_debs do
sh "mkdir -p debs"
Dir.chdir("debs") do
sh "wget http://archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu44_4.4.2-2ubuntu0.11.04.1_i386.deb" unless File.exist?("libicu44_4.4.2-2ubuntu0.11.04.1_i386.deb")
base_url = "https://github.com/downloads/CocoaPods/OpenCFLite"
%w{ opencflite1_248-1_i386.deb opencflite-dev_248-1_i386.deb }.each do |deb|
sh "wget #{File.join(base_url, deb)}" unless File.exist?(deb)
end
sh "sudo dpkg -i *.deb"
end
end
task :install do
sh "git submodule update --init"
sh "sudo apt-get install subversion"
sh "env CFLAGS='-I#{rvm_ruby_dir}/include' bundle install --without debugging documentation"
end end
task :setup => [:install_opencflite_debs, :install]
end end
namespace :gem do namespace :gem do
...@@ -263,33 +231,35 @@ namespace :examples do ...@@ -263,33 +231,35 @@ namespace :examples do
desc "Build all examples" desc "Build all examples"
task :build do task :build do
sh "rm -rf ~/Library/Developer/Shared/Documentation/DocSets/org.cocoapods.*" execute_command "rm -rf ~/Library/Developer/Shared/Documentation/DocSets/org.cocoapods.*"
examples.entries.each do |example| examples.entries.each do |example|
puts "Building example: #{example}" puts "Building example: #{example}"
puts
Dir.chdir(example.to_s) do Dir.chdir(example.to_s) do
sh "rm -rf Pods DerivedData" execute_command "rm -rf Pods DerivedData"
sh "#{'../../bin/' unless ENV['FROM_GEM']}pod install --verbose --no-update" execute_command "#{'../../bin/' unless ENV['FROM_GEM']}pod install --verbose --no-update"
command = "xcodebuild -workspace '#{example.basename}.xcworkspace' -scheme '#{example.basename}'" command = "xcodebuild -workspace '#{example.basename}.xcworkspace' -scheme '#{example.basename}'"
if (example + 'Podfile').read.include?('platform :ios') if (example + 'Podfile').read.include?('platform :ios')
# Specifically build against the simulator SDK so we don't have to deal with code signing. # Specifically build against the simulator SDK so we don't have to deal with code signing.
command << " -sdk " command << " -sdk "
command << Dir.glob("#{`xcode-select -print-path`.chomp}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator*.sdk").last command << Dir.glob("#{`xcode-select -print-path`.chomp}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator*.sdk").last
end end
sh command execute_command(command)
end end
puts
end end
end end
end end
desc "Initializes your working copy to run the specs" desc "Initializes your working copy to run the specs"
task :bootstrap do task :bootstrap do
puts "Updating submodules..." puts "Updating submodules"
`git submodule update --init --recursive` execute_command "git submodule update --init --recursive"
puts "Installing gems" puts "Installing gems"
`bundle install` execute_command "bundle install"
puts "Installing tools (Homebrew)"
execute_command "brew install appledoc" if `which appledoc`.strip.empty?
execute_command "brew install mercurial" if `which hg`.strip.empty?
end end
desc "Run all specs" desc "Run all specs"
......
...@@ -30,7 +30,7 @@ Gem::Specification.new do |s| ...@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'cocoapods-core', "= #{Pod::VERSION}" s.add_runtime_dependency 'cocoapods-core', "= #{Pod::VERSION}"
s.add_runtime_dependency 'claide', '~> 0.1' s.add_runtime_dependency 'claide', '~> 0.1'
s.add_runtime_dependency 'cocoapods-downloader', '~> 0.1' s.add_runtime_dependency 'cocoapods-downloader', '~> 0.1'
s.add_runtime_dependency 'xcodeproj', '~> 0.4.1' s.add_runtime_dependency 'xcodeproj', '~> 0.4.3'
s.add_runtime_dependency 'faraday', '~> 0.8.1' s.add_runtime_dependency 'faraday', '~> 0.8.1'
s.add_runtime_dependency 'octokit', '~> 1.7' s.add_runtime_dependency 'octokit', '~> 1.7'
......
COCOAPODS: 0.16.1
PODS: PODS:
- AFNetworking (0.7.0): - AFNetworking (0.7.0):
- JSONKit - JSONKit
...@@ -22,14 +24,12 @@ DEPENDENCIES: ...@@ -22,14 +24,12 @@ DEPENDENCIES:
- FormatterKit - FormatterKit
SPEC CHECKSUMS: SPEC CHECKSUMS:
AFNetworking: 7bf22b0ed1d9068909cd67206db78204eb63dd2c
FormatterKit: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/ArrayFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/LocationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/OrdinalNumberFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/TimeIntervalFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 FormatterKit/TimeIntervalFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/URLRequestFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 FormatterKit/URLRequestFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/UnitOfInformationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 FormatterKit/UnitOfInformationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
JSONKit: a01a22c75f27eae76b4badd55a91c20fe6e86477 FormatterKit/ArrayFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
JSONKit: 3d4708953ea7ae399a49777372d8b060a43ddd27
COCOAPODS: 0.16.0.rc2 FormatterKit/LocationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
AFNetworking: 7bf22b0ed1d9068909cd67206db78204eb63dd2c
FormatterKit: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/OrdinalNumberFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
...@@ -17,19 +17,19 @@ PODS: ...@@ -17,19 +17,19 @@ PODS:
- FormatterKit/UnitOfInformationFormatter (1.0.0) - FormatterKit/UnitOfInformationFormatter (1.0.0)
- JSONKit (1.5pre) - JSONKit (1.5pre)
DEPENDENCIES:
- AFNetworking (~> 0.7.0)
- FormatterKit
SPEC CHECKSUMS: SPEC CHECKSUMS:
AFNetworking: 7bf22b0ed1d9068909cd67206db78204eb63dd2c
FormatterKit: 12dea999a2df19e389f7b821962fc4088de8b821 FormatterKit: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/ArrayFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/LocationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 FormatterKit/LocationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/UnitOfInformationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/OrdinalNumberFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 FormatterKit/OrdinalNumberFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/TimeIntervalFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/URLRequestFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 FormatterKit/URLRequestFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/UnitOfInformationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 JSONKit: 3d4708953ea7ae399a49777372d8b060a43ddd27
JSONKit: a01a22c75f27eae76b4badd55a91c20fe6e86477 FormatterKit/TimeIntervalFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/ArrayFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
AFNetworking: 7bf22b0ed1d9068909cd67206db78204eb63dd2c
DEPENDENCIES:
- AFNetworking (~> 0.7.0)
- FormatterKit
COCOAPODS: 0.16.0.rc2 COCOAPODS: 0.16.1
*.pbxuser
*.perspectivev3
build
//
// DetailViewController.h
// MGSplitView
//
// Created by Matt Gemmell on 26/07/2010.
// Copyright Instinctive Code 2010.
//
#import <UIKit/UIKit.h>
#import "MGSplitViewController.h"
@interface DetailViewController : UIViewController <UIPopoverControllerDelegate, MGSplitViewControllerDelegate> {
IBOutlet MGSplitViewController *splitController;
IBOutlet UIBarButtonItem *toggleItem;
IBOutlet UIBarButtonItem *verticalItem;
IBOutlet UIBarButtonItem *dividerStyleItem;
IBOutlet UIBarButtonItem *masterBeforeDetailItem;
UIPopoverController *popoverController;
UIToolbar *toolbar;
id detailItem;
UILabel *detailDescriptionLabel;
}
@property (nonatomic, retain) IBOutlet UIToolbar *toolbar;
@property (nonatomic, retain) id detailItem;
@property (nonatomic, retain) IBOutlet UILabel *detailDescriptionLabel;
- (IBAction)toggleMasterView:(id)sender;
- (IBAction)toggleVertical:(id)sender;
- (IBAction)toggleDividerStyle:(id)sender;
- (IBAction)toggleMasterBeforeDetail:(id)sender;
@end
//
// DetailViewController.m
// MGSplitView
//
// Created by Matt Gemmell on 26/07/2010.
// Copyright Instinctive Code 2010.
//
#import "DetailViewController.h"
#import "RootViewController.h"
@interface DetailViewController ()
@property (nonatomic, retain) UIPopoverController *popoverController;
- (void)configureView;
@end
@implementation DetailViewController
@synthesize toolbar, popoverController, detailItem, detailDescriptionLabel;
#pragma mark -
#pragma mark Managing the detail item
// When setting the detail item, update the view and dismiss the popover controller if it's showing.
- (void)setDetailItem:(id)newDetailItem
{
if (detailItem != newDetailItem) {
[detailItem release];
detailItem = [newDetailItem retain];
// Update the view.
[self configureView];
}
if (popoverController != nil) {
[popoverController dismissPopoverAnimated:YES];
}
}
- (void)configureView
{
// Update the user interface for the detail item.
detailDescriptionLabel.text = [detailItem description];
toggleItem.title = ([splitController isShowingMaster]) ? @"Hide Master" : @"Show Master"; // "I... AM... THE MASTER!" Derek Jacobi. Gave me chills.
verticalItem.title = (splitController.vertical) ? @"Horizontal Split" : @"Vertical Split";
dividerStyleItem.title = (splitController.dividerStyle == MGSplitViewDividerStyleThin) ? @"Enable Dragging" : @"Disable Dragging";
masterBeforeDetailItem.title = (splitController.masterBeforeDetail) ? @"Detail First" : @"Master First";
}
#pragma mark -
#pragma mark Split view support
- (void)splitViewController:(MGSplitViewController*)svc
willHideViewController:(UIViewController *)aViewController
withBarButtonItem:(UIBarButtonItem*)barButtonItem
forPopoverController: (UIPopoverController*)pc
{
//NSLog(@"%@", NSStringFromSelector(_cmd));
if (barButtonItem) {
barButtonItem.title = @"Popover";
NSMutableArray *items = [[toolbar items] mutableCopy];
[items insertObject:barButtonItem atIndex:0];
[toolbar setItems:items animated:YES];
[items release];
}
self.popoverController = pc;
}
// Called when the view is shown again in the split view, invalidating the button and popover controller.
- (void)splitViewController:(MGSplitViewController*)svc
willShowViewController:(UIViewController *)aViewController
invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
//NSLog(@"%@", NSStringFromSelector(_cmd));
if (barButtonItem) {
NSMutableArray *items = [[toolbar items] mutableCopy];
[items removeObject:barButtonItem];
[toolbar setItems:items animated:YES];
[items release];
}
self.popoverController = nil;
}
- (void)splitViewController:(MGSplitViewController*)svc
popoverController:(UIPopoverController*)pc
willPresentViewController:(UIViewController *)aViewController
{
//NSLog(@"%@", NSStringFromSelector(_cmd));
}
- (void)splitViewController:(MGSplitViewController*)svc willChangeSplitOrientationToVertical:(BOOL)isVertical
{
//NSLog(@"%@", NSStringFromSelector(_cmd));
}
- (void)splitViewController:(MGSplitViewController*)svc willMoveSplitToPosition:(float)position
{
//NSLog(@"%@", NSStringFromSelector(_cmd));
}
- (float)splitViewController:(MGSplitViewController *)svc constrainSplitPosition:(float)proposedPosition splitViewSize:(CGSize)viewSize
{
//NSLog(@"%@", NSStringFromSelector(_cmd));
return proposedPosition;
}
#pragma mark -
#pragma mark Actions
- (IBAction)toggleMasterView:(id)sender
{
[splitController toggleMasterView:sender];
[self configureView];
}
- (IBAction)toggleVertical:(id)sender
{
[splitController toggleSplitOrientation:self];
[self configureView];
}
- (IBAction)toggleDividerStyle:(id)sender
{
MGSplitViewDividerStyle newStyle = ((splitController.dividerStyle == MGSplitViewDividerStyleThin) ? MGSplitViewDividerStylePaneSplitter : MGSplitViewDividerStyleThin);
[splitController setDividerStyle:newStyle animated:YES];
[self configureView];
}
- (IBAction)toggleMasterBeforeDetail:(id)sender
{
[splitController toggleMasterBeforeDetail:sender];
[self configureView];
}
#pragma mark -
#pragma mark Rotation support
// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[self configureView];
}
- (void)dealloc
{
[popoverController release];
[toolbar release];
[detailItem release];
[detailDescriptionLabel release];
[super dealloc];
}
@end
//
// MGSplitViewAppDelegate.h
// MGSplitView
//
// Created by Matt Gemmell on 26/07/2010.
// Copyright Instinctive Code 2010.
//
#import <UIKit/UIKit.h>
@class RootViewController;
@class DetailViewController;
@class MGSplitViewController;
@interface MGSplitViewAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
MGSplitViewController *splitViewController;
RootViewController *rootViewController;
DetailViewController *detailViewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet MGSplitViewController *splitViewController;
@property (nonatomic, retain) IBOutlet RootViewController *rootViewController;
@property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;
@end
//
// MGSplitViewAppDelegate.m
// MGSplitView
//
// Created by Matt Gemmell on 26/07/2010.
// Copyright Instinctive Code 2010.
//
#import "MGSplitViewAppDelegate.h"
#import "RootViewController.h"
#import "DetailViewController.h"
#import "MGSplitViewController.h"
@implementation MGSplitViewAppDelegate
@synthesize window, splitViewController, rootViewController, detailViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Add the split view controller's view to the window and display.
[window addSubview:splitViewController.view];
[window makeKeyAndVisible];
[rootViewController performSelector:@selector(selectFirstRow) withObject:nil afterDelay:0];
[detailViewController performSelector:@selector(configureView) withObject:nil afterDelay:0];
if (NO) { // whether to allow dragging the divider to move the split.
splitViewController.splitWidth = 15.0; // make it wide enough to actually drag!
splitViewController.allowsDraggingDivider = YES;
}
return YES;
}
- (void)dealloc
{
[splitViewController release];
[window release];
[super dealloc];
}
@end
//
// RootViewController.h
// MGSplitView
//
// Created by Matt Gemmell on 26/07/2010.
// Copyright Instinctive Code 2010.
//
#import <UIKit/UIKit.h>
@class DetailViewController;
@interface RootViewController : UITableViewController {
DetailViewController *detailViewController;
}
@property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;
- (void)selectFirstRow;
@end
//
// RootViewController.m
// MGSplitView
//
// Created by Matt Gemmell on 26/07/2010.
// Copyright Instinctive Code 2010.
//
#import "RootViewController.h"
#import "DetailViewController.h"
@implementation RootViewController
@synthesize detailViewController;
#pragma mark -
#pragma mark View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
}
// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void)selectFirstRow
{
if ([self.tableView numberOfSections] > 0 && [self.tableView numberOfRowsInSection:0] > 0) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionTop];
[self tableView:self.tableView didSelectRowAtIndexPath:indexPath];
}
}
#pragma mark -
#pragma mark Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellIdentifier";
// Dequeue or create a cell of the appropriate type.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
}
// Configure the cell.
cell.textLabel.text = [NSString stringWithFormat:@"Row %d", indexPath.row];
return cell;
}
#pragma mark -
#pragma mark Table view delegate
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// When a row is selected, set the detail view controller's detail item to the item associated with the selected row.
detailViewController.detailItem = [NSString stringWithFormat:@"Row %d", indexPath.row];
}
#pragma mark -
#pragma mark Memory management
- (void)dealloc
{
[detailViewController release];
[super dealloc];
}
@end
This diff is collapsed.
<?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>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.instinctivecode.test.${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>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSMainNibFile</key>
<string>MainWindow</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "MGSplitView.app"
BlueprintName = "MGSplitView"
ReferencedContainer = "container:MGSplitView.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "MGSplitView.app"
BlueprintName = "MGSplitView"
ReferencedContainer = "container:MGSplitView.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "MGSplitView.app"
BlueprintName = "MGSplitView"
ReferencedContainer = "container:MGSplitView.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "MGSplitView.app"
BlueprintName = "MGSplitView"
ReferencedContainer = "container:MGSplitView.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version='1.0' encoding='UTF-8'?><Workspace version='1.0'><FileRef location='group:Pods/Pods.xcodeproj'/><FileRef location='group:MGSplitView.xcodeproj'/></Workspace>
\ No newline at end of file
//
// Prefix header for all source files of the 'MGSplitView' target in the 'MGSplitView' project
//
#import <Availability.h>
#ifndef __IPHONE_3_2
#warning "This project uses features only available in iPhone SDK 3.2 and later."
#endif
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
This diff is collapsed.
platform :ios
pod 'MGSplitViewController', '1.0.0'
PODS:
- MGSplitViewController (1.0.0)
DEPENDENCIES:
- MGSplitViewController (= 1.0.0)
SPEC CHECKSUMS:
MGSplitViewController: e0b0bc01aa81e1559765c39e7a764c890dac373a
COCOAPODS: 0.16.0.rc2
**_NOTE: This is the MGSplitViewController example from https://github.com/mattgemmell/MGSplitViewController, but only updated to use CocoaPods. It does not contain the actual source files that make up the library, because those are fetched when running: $pod install_**
MGSplitViewController
=====================
MGSplitViewController is a replacement for UISplitViewController, with various useful enhancements.
Donations
---------
I wrote MGSplitViewController for my own use, but I'm making it available (as usual) for the benefit of the iOS developer community.
If you find it useful, a Paypal donation (or something from my Amazon.co.uk Wishlist) would be very much appreciated. Appropriate links can be found here: <http://mattgemmell.com/source>
Features
--------
Please note that, since split-views are commonly used for "Master-Detail" interfaces, I call the first sub-view the "master" and the second sub-view the "detail".
- By default, MGSplitViewController mimics the appearance and (complete) behaviour of UISplitViewController, including its delegate API. It accepts two UIViewControllers (or subclasses thereof).
- Allows toggling the _visibility of the master view_ in either interface-orientation; i.e. you can have master-detail or detail-only in either landscape and/or portrait orientations (independently, and/or interactively).
- Allows choosing whether the _split orientation_ is vertical (i.e. left/right, like UISplitViewController), or horizontal (master above, and detail below). You can toggle between modes interactively, with animation.
- Allows choosing whether the master view is _before_ (above, or to left of) the detail view, or _after_ it (below, or to the right).
- Allows you to choose (and change) the _position_ of the split, i.e. the relative sizes of the master and detail views.
- Allows you to enable _dragging_ of the split/divider between the master and detail views, with optional constraining via a delegate method.
- Allows you to choose the _width of the split_ between the master and detail views.
- Preset "_divider styles_": one for non-draggable UISplitViewController-like dividers, and one for draggable, thicker style with a grip-strip.
- Allows you to substitute your own divider-view (an MGSplitDividerView subclass), used to draw the split between the master and detail views.
How to use
----------
The "MGSplitViewController.h" header file (and the sample project) should be self-explanatory. It's recommended that you use the project as a reference.
Interface Builder support
-------------------------
At time of writing, MGSplitViewController cannot be quite as elegantly _visually_ configured like UISplitViewController using Interface Builder.
You can, however, (and it is recommended that you do) create an instance of it in a xib, and connect the masterViewController and detailViewController outlets to the required view-controllers.
License and Warranty
--------------------
The license for the code is included with the project; it's basically a BSD license with attribution.
You're welcome to use it in commercial, closed-source, open source, free or any other kind of software, as long as you credit me appropriately.
The MGSplitViewController code comes with no warranty of any kind. I hope it'll be useful to you (it certainly is to me), but I make no guarantees regarding its functionality or otherwise.
Support / Contact / Bugs / Features
-----------------------------------
I can't answer any questions about how to use the code, but I always welcome emails telling me that you're using it, or just saying thanks.
If you create an app which uses the code, I'd also love to hear about it. You can find my contact details on my web site, listed below.
Likewise, if you want to submit a feature request or bug report, feel free to get in touch. Better yet, fork the code and implement the feature/fix yourself, then submit a pull request.
Enjoy the code!
Cheers,
Matt Legend Gemmell
Writing: http://mattgemmell.com/
Contact: http://mattgemmell.com/about
Twitter: http://twitter.com/mattgemmell
Hire Me: http://instinctivecode.com/
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
{\colortbl;\red255\green255\blue255;\red51\green51\blue51;\red0\green180\blue128;\red255\green0\blue0;
\red31\green105\blue199;\red119\green119\blue119;}
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid1\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid1}}
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}}
\deftab720
\pard\pardeftab720\ql\qnatural
\f0\b\fs24 \cf2 Matt Legend Gemmell / Instinctive Code Source Code License\
\b0\fs22 Last updated: 9th May 2010
\fs24 \
\
\
Thanks for downloading some of our source code!\
\
This is the license agreement for the source code which this document accompanies (don\'92t worry: you\'92re allowed to use it in your own products, commercial or otherwise).\
\
The full license text is further down this page, and you should only use the source code if you agree to the terms in that text. For convenience, though, we\'92ve put together a human-readable
\b non-authoritative
\b0 interpretation of the license which will hopefully answer any questions you have.\
\
\
\b \cf3 Green
\b0 \cf2 text shows
\b \cf3 what you can do with the code
\b0 \cf2 .\
\b \cf4 Red
\b0 \cf2 text means
\b \cf4 restrictions you must abide by
\b0 \cf2 .\
\
Basically, the license says that:\
\
\pard\tx220\tx720\pardeftab720\li720\fi-720\ql\qnatural
\ls1\ilvl0\cf2 {\listtext 1. }You can
\b \cf3 use the code in your own products, including commercial and/or closed-source products
\b0 \cf2 .\
{\listtext 2. }You can
\b \cf3 modify the code
\b0 \cf0 as you wish\cf2 , and
\b \cf3 use the modified code in your products
\b0 \cf2 .\
{\listtext 3. }You can
\b \cf3 redistribute the original, unmodified code
\b0 \cf2 , but you
\b \cf4 have to include the full license text below
\b0 \cf2 .\
{\listtext 4. }You can
\b \cf3 redistribute the modified code
\b0 \cf2 as you wish (
\b \cf4 without the full license text below
\b0 \cf2 ).\
{\listtext 5. }In all cases, you
\b \cf4 must include a credit mentioning Matt Legend Gemmell
\b0 \cf2 as the original author of the source.\
{\listtext 6. }Matt Legend Gemmell is \cf0 not liable for anything you do with the code\cf2 , no matter what. So be sensible.\
{\listtext 7. }You
\b \cf4 can\'92t use the name Matt Legend Gemmell, the name Instinctive Code, the Instinctive Code logo or any other related marks to promote your products
\b0 \cf2 based on the code.\
{\listtext 8. }If you agree to all of that, go ahead and use the source. Otherwise, don\'92t!\
\pard\pardeftab720\ql\qnatural
\cf2 \
\b \
\
Suggested Attribution Format\
\b0 \
The license requires that you give credit to Matt Legend Gemmell, as the original author of any of our source that you use. The placement and format of the credit is up to you, but we prefer the credit to be in the software\'92s \'93About\'94 window. Alternatively, you could put the credit in a list of acknowledgements within the software, in the software\'92s documentation, or on the web page for the software. The suggested format for the attribution is:\
\
\pard\pardeftab720\ql\qnatural
\b \cf0 Includes <Name of Code> code by {\field{\*\fldinst{HYPERLINK "http://mattgemmell.com/"}}{\fldrslt \cf5 Matt Legend Gemmell}}\cf6 .
\b0 \
\pard\pardeftab720\ql\qnatural
\cf2 \
where <Name of Code> would be replaced by the name of the specific source-code package you made use of. Where possible, please link the text \'93Matt Legend Gemmell\'94 to the following URL, or include the URL as plain text: {\field{\*\fldinst{HYPERLINK "http://mattgemmell.com/"}}{\fldrslt \cf5 http://mattgemmell.com/}}\
\
\
\b Full Source Code License Text\
\
\b0 Below you can find the actual text of the license agreement.
\b \
\
\pard\pardeftab720\ql\qnatural
\cf6 \
License Agreement for Source Code provided by Matt Legend Gemmell
\b0 \
\
This software is supplied to you by Matt Legend Gemmell in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this software.\
\
In consideration of your agreement to abide by the following terms, and subject to these terms, Matt Legend Gemmell grants you a personal, non-exclusive license, to use, reproduce, modify and redistribute the software, with or without modifications, in source and/or binary forms; provided that if you redistribute the software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the software, and that in all cases attribution of Matt Legend Gemmell as the original author of the source code shall be included in all such resulting software products or distributions.\uc0\u8232 \
Neither the name, trademarks, service marks or logos of Matt Legend Gemmell or Instinctive Code may be used to endorse or promote products derived from the software without specific prior written permission from Matt Legend Gemmell. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Matt Legend Gemmell herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the software may be incorporated.\
\
The software is provided by Matt Legend Gemmell on an "AS IS" basis. MATT LEGEND GEMMELL AND INSTINCTIVE CODE MAKE NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.\
\
IN NO EVENT SHALL MATT LEGEND GEMMELL OR INSTINCTIVE CODE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF MATT LEGEND GEMMELL OR INSTINCTIVE CODE HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\
}
\ No newline at end of file
TODO
====
Interface Builder
-----------------
- Support visual configuration in Interface Builder, like UISplitViewController?
//
// main.m
// MGSplitView
//
// Created by Matt Gemmell on 26/07/2010.
// Copyright Instinctive Code 2010. All rights reserved.
//
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
//
// RKTStatus.h
// RKTwitter
//
// Created by Blake Watters on 9/5/10.
// Copyright (c) 2009-2012 RestKit. All rights reserved.
//
#import "RKTUser.h"
@interface RKTStatus : NSObject {
NSNumber* _statusID;
NSDate* _createdAt;
NSString* _text;
NSString* _urlString;
NSString* _inReplyToScreenName;
NSNumber* _isFavorited;
RKTUser* _user;
}
/**
* The unique ID of this Status
*/
@property (nonatomic, retain) NSNumber* statusID;
/**
* Timestamp the Status was sent
*/
@property (nonatomic, retain) NSDate* createdAt;
/**
* Text of the Status
*/
@property (nonatomic, retain) NSString* text;
/**
* String version of the URL associated with the Status
*/
@property (nonatomic, retain) NSString* urlString;
/**
* The screen name of the User this Status was in response to
*/
@property (nonatomic, retain) NSString* inReplyToScreenName;
/**
* Is this status a favorite?
*/
@property (nonatomic, retain) NSNumber* isFavorited;
/**
* The User who posted this status
*/
@property (nonatomic, retain) RKTUser* user;
@end
//
// RKTStatus.m
// RKTwitter
//
// Created by Blake Watters on 9/5/10.
// Copyright (c) 2009-2012 RestKit. All rights reserved.
//
#import "RKTStatus.h"
@implementation RKTStatus
@synthesize statusID = _statusID;
@synthesize createdAt = _createdAt;
@synthesize text = _text;
@synthesize urlString = _urlString;
@synthesize inReplyToScreenName = _inReplyToScreenName;
@synthesize isFavorited = _isFavorited;
@synthesize user = _user;
- (NSString*)description {
return [NSString stringWithFormat:@"%@ (ID: %@)", self.text, self.statusID];
}
- (void)dealloc {
[_statusID release];
[_createdAt release];
[_text release];
[_urlString release];
[_inReplyToScreenName release];
[_user release];
[super dealloc];
}
@end
//
// RKTUser.h
// RKTwitter
//
// Created by Blake Watters on 9/5/10.
// Copyright (c) 2009-2012 RestKit. All rights reserved.
//
@interface RKTUser : NSObject {
NSNumber* _userID;
NSString* _name;
NSString* _screenName;
}
@property (nonatomic, retain) NSNumber* userID;
@property (nonatomic, retain) NSString* name;
@property (nonatomic, retain) NSString* screenName;
@end
//
// RKTUser.m
// RKTwitter
//
// Created by Blake Watters on 9/5/10.
// Copyright (c) 2009-2012 RestKit. All rights reserved.
//
#import "RKTUser.h"
@implementation RKTUser
@synthesize userID = _userID;
@synthesize name = _name;
@synthesize screenName = _screenName;
- (void)dealloc {
[_userID release];
[_name release];
[_screenName release];
[super dealloc];
}
@end
//
// RKTwitterAppDelegate.h
// RKTwitter
//
// Created by Blake Watters on 9/5/10.
// Copyright (c) 2009-2012 RestKit. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface RKTwitterAppDelegate : NSObject <UIApplicationDelegate> {
}
@end
//
// RKTwitterAppDelegate.m
// RKTwitter
//
// Created by Blake Watters on 9/5/10.
// Copyright (c) 2009-2012 RestKit. All rights reserved.
//
#import <RestKit/RestKit.h>
#import "RKTwitterAppDelegate.h"
#import "RKTwitterViewController.h"
#import "RKTStatus.h"
#import "RKTUser.h"
@implementation RKTwitterAppDelegate
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
RKLogConfigureByName("RestKit/Network*", RKLogLevelTrace);
RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);
// Initialize RestKit
RKObjectManager* objectManager = [RKObjectManager managerWithBaseURLString:@"http://twitter.com"];
// Enable automatic network activity indicator management
objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES;
// Setup our object mappings
RKObjectMapping* userMapping = [RKObjectMapping mappingForClass:[RKTUser class]];
[userMapping mapKeyPath:@"id" toAttribute:@"userID"];
[userMapping mapKeyPath:@"screen_name" toAttribute:@"screenName"];
[userMapping mapAttributes:@"name", nil];
RKObjectMapping* statusMapping = [RKObjectMapping mappingForClass:[RKTStatus class]];
[statusMapping mapKeyPathsToAttributes:@"id", @"statusID",
@"created_at", @"createdAt",
@"text", @"text",
@"url", @"urlString",
@"in_reply_to_screen_name", @"inReplyToScreenName",
@"favorited", @"isFavorited",
nil];
[statusMapping mapRelationship:@"user" withMapping:userMapping];
// Update date format so that we can parse Twitter dates properly
// Wed Sep 29 15:31:08 +0000 2010
[RKObjectMapping addDefaultDateFormatterForString:@"E MMM d HH:mm:ss Z y" inTimeZone:nil];
// Uncomment these lines to use XML, comment it to use JSON
// objectManager.acceptMIMEType = RKMIMETypeXML;
// statusMapping.rootKeyPath = @"statuses.status";
// Register our mappings with the provider using a resource path pattern
[objectManager.mappingProvider setObjectMapping:statusMapping forResourcePathPattern:@"/status/user_timeline/:username"];
// Create Window and View Controllers
RKTwitterViewController* viewController = [[[RKTwitterViewController alloc] initWithNibName:nil bundle:nil] autorelease];
UINavigationController* controller = [[UINavigationController alloc] initWithRootViewController:viewController];
UIWindow* window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[window addSubview:controller.view];
[window makeKeyAndVisible];
return YES;
}
- (void)dealloc {
[super dealloc];
}
@end
//
// RKTwitterViewController.h
// RKTwitter
//
// Created by Blake Watters on 9/5/10.
// Copyright (c) 2009-2012 RestKit. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <RestKit/RestKit.h>
@interface RKTwitterViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, RKObjectLoaderDelegate> {
UITableView* _tableView;
NSArray* _statuses;
}
@end
//
// RKTwitterViewController.m
// RKTwitter
//
// Created by Blake Watters on 9/5/10.
// Copyright (c) 2009-2012 RestKit. All rights reserved.
//
#import "RKTwitterViewController.h"
#import "RKTStatus.h"
@interface RKTwitterViewController (Private)
- (void)loadData;
@end
@implementation RKTwitterViewController
- (void)loadTimeline {
// Load the object model via RestKit
RKObjectManager* objectManager = [RKObjectManager sharedManager];
objectManager.client.baseURL = [RKURL URLWithString:@"http://www.twitter.com"];
[objectManager loadObjectsAtResourcePath:@"/status/user_timeline/RestKit" delegate:self];
}
- (void)loadView {
[super loadView];
// Setup View and Table View
self.title = @"RestKit Tweets";
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(loadTimeline)] autorelease];
UIImageView* imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BG.png"]] autorelease];
imageView.frame = CGRectOffset(imageView.frame, 0, -64);
[self.view insertSubview:imageView atIndex:0];
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 480-64) style:UITableViewStylePlain];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.backgroundColor = [UIColor clearColor];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.view addSubview:_tableView];
[self loadTimeline];
}
- (void)dealloc {
[_tableView release];
[_statuses release];
[super dealloc];
}
#pragma mark RKObjectLoaderDelegate methods
- (void)request:(RKRequest*)request didLoadResponse:(RKResponse*)response {
NSLog(@"Loaded payload: %@", [response bodyAsString]);
}
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects {
NSLog(@"Loaded statuses: %@", objects);
[_statuses release];
_statuses = [objects retain];
[_tableView reloadData];
}
- (void)objectLoader:(RKObjectLoader*)objectLoader didFailWithError:(NSError*)error {
UIAlertView* alert = [[[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
[alert show];
NSLog(@"Hit error: %@", error);
}
#pragma mark UITableViewDelegate methods
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
CGSize size = [[[_statuses objectAtIndex:indexPath.row] text] sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(300, 9000)];
return size.height + 10;
}
#pragma mark UITableViewDataSource methods
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
return [_statuses count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString* reuseIdentifier = @"Tweet Cell";
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
if (nil == cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier] autorelease];
cell.textLabel.font = [UIFont systemFontOfSize:14];
cell.textLabel.numberOfLines = 0;
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"listbg.png"]];
}
cell.textLabel.text = [[_statuses objectAtIndex:indexPath.row] text];
return cell;
}
@end
platform :ios
pod 'RestKit'
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:RKTwitter.xcodeproj">
</FileRef>
</Workspace>
<?xml version='1.0' encoding='UTF-8'?><Workspace version='1.0'><FileRef location='group:Pods/Pods.xcodeproj'/><FileRef location='group:RKTwitter.xcodeproj'/></Workspace>
\ No newline at end of file
//
// Prefix header for all source files of the 'RKTwitter' target in the 'RKTwitter' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
<?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>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.${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>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
</dict>
</plist>
//
// main.m
// RKTwitter
//
// Created by Blake Watters on 9/5/10.
// Copyright (c) 2009-2012 RestKit. All rights reserved.
//
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"RKTwitterAppDelegate");
[pool release];
return retVal;
}
# As this file is loaded pretty early, we can use this opportunity to clean
# the integrated project, if it exists, and setup an unintegrated version.
require 'fileutils'
integrated = File.expand_path('../RelativePathProject/RelativePathProject.xcodeproj', __FILE__)
unintegrated = File.expand_path('../RelativePathProject/RelativePathProject.xcodeproj.unintegrated', __FILE__)
FileUtils.rm_rf(integrated)
FileUtils.cp_r(unintegrated, integrated)
platform :ios
xcodeproj "RelativePathProject/RelativePathProject.xcodeproj"
pod "AFNetworking"
<?xml version='1.0' encoding='UTF-8'?><Workspace version='1.0'><FileRef location='group:Pods/Pods.xcodeproj'/><FileRef location='group:RelativePathProject/RelativePathProject.xcodeproj'/></Workspace>
\ No newline at end of file
//
// CCPAppDelegate.h
// RelativePathProject
//
// Created by Ben Scheirman on 3/8/12.
// Copyright (c) 2012 ChaiONE. All rights reserved.
//
#import <UIKit/UIKit.h>
@class CCPViewController;
@interface CCPAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) CCPViewController *viewController;
@end
//
// CCPAppDelegate.m
// RelativePathProject
//
// Created by Ben Scheirman on 3/8/12.
// Copyright (c) 2012 ChaiONE. All rights reserved.
//
#import "CCPAppDelegate.h"
#import "CCPViewController.h"
@implementation CCPAppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
- (void)dealloc
{
[_window release];
[_viewController release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[[CCPViewController alloc] initWithNibName:@"CCPViewController_iPhone" bundle:nil] autorelease];
} else {
self.viewController = [[[CCPViewController alloc] initWithNibName:@"CCPViewController_iPad" bundle:nil] autorelease];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
//
// CCPViewController.h
// RelativePathProject
//
// Created by Ben Scheirman on 3/8/12.
// Copyright (c) 2012 ChaiONE. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CCPViewController : UIViewController
@end
//
// CCPViewController.m
// RelativePathProject
//
// Created by Ben Scheirman on 3/8/12.
// Copyright (c) 2012 ChaiONE. All rights reserved.
//
#import "CCPViewController.h"
@interface CCPViewController ()
@end
@implementation CCPViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
@end
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.cocoapods.${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>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
//
// Prefix header for all source files of the 'RelativePathProject' target in the 'RelativePathProject' project
//
#import <Availability.h>
#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1280</int>
<string key="IBDocument.SystemVersion">11C25</string>
<string key="IBDocument.InterfaceBuilderVersion">1919</string>
<string key="IBDocument.AppKitVersion">1138.11</string>
<string key="IBDocument.HIToolboxVersion">566.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">916</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
<string>IBUIView</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">IBIPadFramework</string>
</object>
<object class="IBProxyObject" id="606714003">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
<object class="IBUIView" id="766721923">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<string key="NSFrame">{{0, 20}, {768, 1004}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
<object class="NSColorSpace" key="NSCustomColorSpace">
<int key="NSID">2</int>
</object>
</object>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics">
<int key="IBUIStatusBarStyle">2</int>
</object>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</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="766721923"/>
</object>
<int key="connectionID">3</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="606714003"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="766721923"/>
<reference key="parent" ref="0"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.CustomClassName">CCPViewController</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">3</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">CCPViewController</string>
<string key="superclassName">UIViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/CCPViewController.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>
<string key="IBCocoaTouchPluginVersion">916</string>
</data>
</archive>
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1280</int>
<string key="IBDocument.SystemVersion">11C25</string>
<string key="IBDocument.InterfaceBuilderVersion">1919</string>
<string key="IBDocument.AppKitVersion">1138.11</string>
<string key="IBDocument.HIToolboxVersion">566.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">916</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
<string>IBUIView</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">IBCocoaTouchFramework</string>
</object>
<object class="IBProxyObject" id="843779117">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="774585933">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC43NQA</bytes>
<object class="NSColorSpace" key="NSCustomColorSpace">
<int key="NSID">2</int>
</object>
</object>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</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="774585933"/>
</object>
<int key="connectionID">7</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="843779117"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">6</int>
<reference key="object" ref="774585933"/>
<reference key="parent" ref="0"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.CustomClassName">CCPViewController</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="6.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">7</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">CCPViewController</string>
<string key="superclassName">UIViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/CCPViewController.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>
<string key="IBCocoaTouchPluginVersion">916</string>
</data>
</archive>
//
// main.m
// RelativePathProject
//
// Created by Ben Scheirman on 3/8/12.
// Copyright (c) 2012 ChaiONE. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CCPAppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([CCPAppDelegate class]));
}
}
.DS_Store
*.mode1v3
*.pbxuser
*.perspectivev3
*.xcworkspace
xcuserdata
Documentation
[submodule "Vendor/AFNetworking"]
path = Vendor/AFNetworking
url = https://github.com/gowalla/AFNetworking.git
[submodule "Vendor/SSToolkit"]
path = Vendor/SSToolkit
url = https://github.com/samsoffes/sstoolkit.git
//
// SCAddressBarDemoViewController.h
// SSCatalog
//
// Created by Sam Soffes on 2/8/11.
// Copyright 2011 Sam Soffes. All rights reserved.
//
@interface SCAddressBarDemoViewController : UIViewController <UITextFieldDelegate, SSWebViewDelegate>
+ (NSString *)title;
@end
//
// SCAddressBarDemoViewController.m
// SSCatalog
//
// Created by Sam Soffes on 2/8/11.
// Copyright 2011 Sam Soffes. All rights reserved.
//
#import "SCAddressBarDemoViewController.h"
@implementation SCAddressBarDemoViewController {
SSGradientView *_headerView;
UILabel *_titleLabel;
SSAddressBarTextField *_addressBar;
SSWebView *_webView;
}
#pragma mark - Class Methods
+ (NSString *)title {
return @"Address bar";
}
#pragma mark - NSObject
- (void)dealloc {
_webView.delegate = nil;
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = [[self class] title];
self.view.backgroundColor = [UIColor colorWithRed:0.851f green:0.859f blue:0.882f alpha:1.0f];
CGSize size = self.view.frame.size;
_headerView = [[SSGradientView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, size.width, 58.0f)];
_headerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_headerView.topColor = [UIColor colorWithWhite:0.957f alpha:1.0f];
_headerView.bottomColor = [UIColor colorWithWhite:0.827f alpha:1.0f];
_headerView.bottomBorderColor = [UIColor colorWithWhite:0.369f alpha:1.0f];
_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10.0f, 0.0f, size.width - 20.0f, 21.0f)];
_titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_titleLabel.backgroundColor = [UIColor clearColor];
_titleLabel.textColor = [UIColor colorWithWhite:0.404f alpha:1.0f];
_titleLabel.textAlignment = UITextAlignmentCenter;
_titleLabel.font = [UIFont boldSystemFontOfSize:12.0f];
_titleLabel.shadowColor = [UIColor whiteColor];
_titleLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
[_headerView addSubview:_titleLabel];
_addressBar = [[SSAddressBarTextField alloc] initWithFrame:CGRectMake(10.0f, 21.0f, size.width - 20.0f, 31.0f)];
_addressBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_addressBar.delegate = self;
[_headerView addSubview:_addressBar];
[self.view addSubview:_headerView];
_webView = [[SSWebView alloc] initWithFrame:CGRectMake(0.0f, 58.0f, size.width, size.height - 58.0f)];
_webView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_webView.scalesPageToFit = YES;
_webView.delegate = self;
[self.view addSubview:_webView];
[_addressBar.reloadButton addTarget:_webView action:@selector(reload) forControlEvents:UIControlEventTouchUpInside];
[_addressBar.stopButton addTarget:_webView action:@selector(stopLoading) forControlEvents:UIControlEventTouchUpInside];
[_webView loadURLString:@"http://samsoff.es"];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
return toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
return YES;
}
#pragma mark - UITextFieldDelegate
- (void)textFieldDidBeginEditing:(UITextField *)textField {
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(_removeGrayView) object:nil];
// Gray Button
// UIButton *aGrayButton = [UIButton buttonWithType:UIButtonTypeCustom];
// aGrayButton.frame = _webView.frame;
// aGrayButton.backgroundColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.5f];
// aGrayButton.alpha = 0.0f;
// aGrayButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// [aGrayButton addTarget:textField action:@selector(resignFirstResponder) forControlEvents:UIControlEventTouchDown];
// self.grayButton = aGrayButton;
// [self.view addSubview:grayButton];
// [grayButton fadeIn];
}
- (void)textFieldDidEndEditing:(UITextField *)textField {
// [self performSelector:@selector(_removeGrayView) withObject:nil afterDelay:0.1];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[_webView loadURLString:textField.text];
[textField resignFirstResponder];
return YES;
}
#pragma mark - SSWebViewDelegate
- (void)webViewDidStartLoadingPage:(SSWebView *)aWebView {
_addressBar.loading = YES;
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
NSString *urlString = [[[_webView lastRequest] mainDocumentURL] absoluteString];
static NSRegularExpression *regularExpression = nil;
if (!regularExpression) {
regularExpression = [[NSRegularExpression alloc] initWithPattern:@"^https?://" options:NSRegularExpressionCaseInsensitive error:nil];
}
NSString *addressBarUrlString = [regularExpression stringByReplacingMatchesInString:urlString options:0 range:NSMakeRange(0, [urlString length]) withTemplate:@""];
_addressBar.text = addressBarUrlString;
_titleLabel.text = urlString;
}
- (void)webViewDidFinishLoadingPage:(SSWebView *)aWebView {
_addressBar.loading = NO;
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
NSString *title = [_webView stringByEvaluatingJavaScriptFromString:@"document.title"];
if (title) {
_titleLabel.text = title;
}
}
- (void)webView:(SSWebView *)aWebView didFailLoadWithError:(NSError *)error {
_addressBar.loading = NO;
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}
@end
//
// SCAppDelegate.h
// SSCatalog
//
// Created by Sam Soffes on 9/21/09.
// Copyright 2009 Sam Soffes, Inc. All rights reserved.
//
@interface SCAppDelegate : NSObject <UIApplicationDelegate>
@property (nonatomic, strong) UIWindow *window;
@property (nonatomic, strong) UINavigationController *navigationController;
@end
//
// SCAppDelegate.m
// SSCatalog
//
// Created by Sam Soffes on 9/21/09.
// Copyright 2009 Sam Soffes, Inc. All rights reserved.
//
#import "SCAppDelegate.h"
#import "SCRootViewController.h"
@implementation SCAppDelegate {
UIWindow *_window;
UINavigationController *_navigationController;
}
#pragma mark - Accessors
@synthesize window = _window;
@synthesize navigationController = _navigationController;
#pragma mark - UIApplicationDelegate
- (void)applicationDidFinishLaunching:(UIApplication *)application {
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
SCRootViewController *viewController = [[SCRootViewController alloc] initWithStyle:UITableViewStyleGrouped];
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
self.navigationController = aNavigationController;
[_window addSubview:_navigationController.view];
[_window makeKeyAndVisible];
}
@end
//
// SCBadgeTableViewCellDemoViewController.m
// SSCatalog
//
// Created by Sam Soffes on 01/29/11.
// Copyright 2011 Sam Soffes, Inc. All rights reserved.
//
@interface SCBadgeTableViewCellDemoViewController : UITableViewController
+ (NSString *)title;
@end
//
// SCBadgeTableViewCellDemoViewController.m
// SSCatalog
//
// Created by Sam Soffes on 01/29/11.
// Copyright 2011 Sam Soffes, Inc. All rights reserved.
//
#import "SCBadgeTableViewCellDemoViewController.h"
@implementation SCBadgeTableViewCellDemoViewController
#pragma mark - Class Methods
+ (NSString *)title {
return @"Badge Table View Cell";
}
#pragma mark - NSObject
- (id)init {
return self = [super initWithStyle:UITableViewStyleGrouped];
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = [[self class] title];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.tableView reloadData];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
return toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
return YES;
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return (section == 0) ? 4 : 12;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"cell";
SSBadgeTableViewCell *cell = (SSBadgeTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[SSBadgeTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier];
}
if (indexPath.section == 0) {
switch (indexPath.row) {
case 0: {
cell.textLabel.text = @"Default Badge View";
cell.badgeView.textLabel.text = @"0";
cell.badgeView.badgeColor = [SSBadgeView defaultBadgeColor];
break;
}
case 1: {
cell.textLabel.text = @"Unread Count";
cell.badgeView.textLabel.text = @"3";
cell.badgeView.badgeColor = [UIColor colorWithRed:0.969f green:0.082f blue:0.078f alpha:1.0f];
break;
}
case 2: {
cell.textLabel.text = @"Text Badge";
cell.badgeView.textLabel.text = @"New";
cell.badgeView.badgeColor = [UIColor colorWithRed:0.388f green:0.686f blue:0.239f alpha:1.0f];
break;
}
case 3: {
cell.textLabel.text = @"Nil value";
cell.badgeView.textLabel.text = nil;
cell.badgeView.badgeColor = [SSBadgeView defaultBadgeColor];
break;
}
}
} else {
NSNumber *number = [NSNumber numberWithInteger:indexPath.row * 256];
cell.textLabel.text = [[NSNumberFormatter localizedStringFromNumber:number numberStyle:NSNumberFormatterSpellOutStyle] capitalizedString];
cell.badgeView.textLabel.text = [NSNumberFormatter localizedStringFromNumber:number numberStyle:NSNumberFormatterDecimalStyle];
cell.badgeView.badgeColor = [SSBadgeView defaultBadgeColor];
}
return cell;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end
//
// SCCollectionViewDemoViewController.h
// SSCatalog
//
// Created by Sam Soffes on 8/24/10.
// Copyright 2010 Sam Soffes. All rights reserved.
//
@interface SCCollectionViewDemoViewController : SSCollectionViewController
+ (NSString *)title;
@end
//
// SCCollectionViewDemoViewController.m
// SSCatalog
//
// Created by Sam Soffes on 8/24/10.
// Copyright 2010 Sam Soffes. All rights reserved.
//
#import "SCCollectionViewDemoViewController.h"
#import "SCImageCollectionViewItem.h"
@implementation SCCollectionViewDemoViewController
#pragma mark - Class Methods
+ (NSString *)title {
return @"Collection View";
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = [[self class] title];
self.collectionView.extremitiesStyle = SSCollectionViewExtremitiesStyleScrolling;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
return toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
return YES;
}
#pragma mark - SSCollectionViewDataSource
- (NSUInteger)numberOfSectionsInCollectionView:(SSCollectionView *)aCollectionView {
return 10;
}
- (NSUInteger)collectionView:(SSCollectionView *)aCollectionView numberOfItemsInSection:(NSUInteger)section {
return 50;
}
- (SSCollectionViewItem *)collectionView:(SSCollectionView *)aCollectionView itemForIndexPath:(NSIndexPath *)indexPath {
static NSString *const itemIdentifier = @"itemIdentifier";
SCImageCollectionViewItem *item = (SCImageCollectionViewItem *)[aCollectionView dequeueReusableItemWithIdentifier:itemIdentifier];
if (item == nil) {
item = [[SCImageCollectionViewItem alloc] initWithReuseIdentifier:itemIdentifier];
}
CGFloat size = 80.0f * [[UIScreen mainScreen] scale];
NSInteger i = (50 * indexPath.section) + indexPath.row;
item.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.gravatar.com/avatar/%i?s=%0.f&d=identicon", i, size]];
return item;
}
- (UIView *)collectionView:(SSCollectionView *)aCollectionView viewForHeaderInSection:(NSUInteger)section {
SSLabel *header = [[SSLabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.view.frame.size.width, 40.0f)];
header.autoresizingMask = UIViewAutoresizingFlexibleWidth;
header.text = [NSString stringWithFormat:@"Section %i", section + 1];
header.textEdgeInsets = UIEdgeInsetsMake(0.0f, 19.0f, 0.0f, 19.0f);
header.shadowColor = [UIColor whiteColor];
header.shadowOffset = CGSizeMake(0.0f, 1.0f);
header.backgroundColor = [UIColor colorWithWhite:1.0f alpha:0.8f];
return header;
}
#pragma mark - SSCollectionViewDelegate
- (CGSize)collectionView:(SSCollectionView *)aCollectionView itemSizeForSection:(NSUInteger)section {
return CGSizeMake(80.0f, 80.0f);
}
- (void)collectionView:(SSCollectionView *)aCollectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
NSString *title = [NSString stringWithFormat:@"You selected item %i in section %i!",
indexPath.row + 1, indexPath.section + 1];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:nil delegate:nil
cancelButtonTitle:@"Oh, awesome!" otherButtonTitles:nil];
[alert show];
}
- (CGFloat)collectionView:(SSCollectionView *)aCollectionView heightForHeaderInSection:(NSUInteger)section {
return 40.0f;
}
@end
//
// SCGradientViewDemoViewController.h
// SSCatalog
//
// Created by Sam Soffes on 10/27/09.
// Copyright 2009 Sam Soffes, Inc. All rights reserved.
//
@interface SCGradientViewDemoViewController : UIViewController
+ (NSString *)title;
- (void)changeColor:(id)sender;
- (void)updateScale:(id)sender;
@end
//
// SCGradientViewDemoViewController.m
// SSCatalog
//
// Created by Sam Soffes on 10/27/09.
// Copyright 2009 Sam Soffes, Inc. All rights reserved.
//
#import "SCGradientViewDemoViewController.h"
@implementation SCGradientViewDemoViewController {
BOOL _blue;
SSGradientView *_gradientView;
}
#pragma mark - Class Methods
+ (NSString *)title {
return @"Gradient View";
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = [[self class] title];
self.view.backgroundColor = [UIColor whiteColor];
// Gradient view
_gradientView = [[SSGradientView alloc] initWithFrame:CGRectMake(20.0f, 20.0f, 280.0f, 280.0f)];
_gradientView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_gradientView.topBorderColor = [UIColor colorWithRed:0.558f green:0.599f blue:0.643f alpha:1.0f];
_gradientView.topInsetColor = [UIColor colorWithWhite:1.0f alpha:0.3f];
_gradientView.colors = [NSArray arrayWithObjects:
[UIColor colorWithRed:0.676f green:0.722f blue:0.765f alpha:1.0f],
[UIColor colorWithRed:0.514f green:0.568f blue:0.617f alpha:1.0f],
nil];
_gradientView.bottomBorderColor = [UIColor colorWithRed:0.428f green:0.479f blue:0.520f alpha:1.0f];
[self.view addSubview:_gradientView];
// Change color button
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(20.0f, 320.0f, 280.0f, 37.0f);
[button setTitle:@"Change Color" forState:UIControlStateNormal];
[button addTarget:self action:@selector(changeColor:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
// Scale slider
UISlider *scaleSlider = [[UISlider alloc] initWithFrame:CGRectMake(20.0f, 377.0f, 280.0f, 20.0f)];
scaleSlider.value = 1.0f;
scaleSlider.minimumValue = 0.0f;
scaleSlider.maximumValue = 1.0f;
[scaleSlider addTarget:self action:@selector(updateScale:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:scaleSlider];
_blue = YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
return toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
return YES;
}
#pragma mark - Actions
- (void)changeColor:(id)sender {
if (_blue) {
_gradientView.colors = [NSArray arrayWithObjects:
[UIColor redColor],
[UIColor orangeColor],
nil];
} else {
_gradientView.colors = [NSArray arrayWithObjects:
[UIColor colorWithRed:0.676f green:0.722f blue:0.765f alpha:1.0f],
[UIColor colorWithRed:0.514f green:0.568f blue:0.617f alpha:1.0f],
nil];
}
_blue = !_blue;
}
- (void)updateScale:(id)sender {
_gradientView.gradientScale = [(UISlider *)sender value];
}
@end
//
// SCHUDViewDemoViewController.h
// SSCatalog
//
// Created by Sam Soffes on 11/18/09.
// Copyright 2009 Sam Soffes, Inc. All rights reserved.
//
@interface SCHUDViewDemoViewController : UIViewController
+ (NSString *)title;
- (void)complete:(id)sender;
- (void)pop:(id)sender;
@end
//
// SCHUDViewDemoViewController.m
// SSCatalog
//
// Created by Sam Soffes on 11/18/09.
// Copyright 2009 Sam Soffes, Inc. All rights reserved.
//
#import "SCHUDViewDemoViewController.h"
@implementation SCHUDViewDemoViewController {
SSHUDView *_hud;
}
#pragma mark - Class Methods
+ (NSString *)title {
return @"HUD View";
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = [[self class] title];
self.view.backgroundColor = [UIColor whiteColor];
// Show HUD
_hud = [[SSHUDView alloc] initWithTitle:@"Loading..."];
// _hud.hudSize = CGSizeMake(60.0f, 60.0f);
// _hud.textLabelHidden = YES;
// _hud.hidesVignette = YES;
[_hud show];
// After 2 seconds, complete action
[self performSelector:@selector(complete:) withObject:nil afterDelay:2.0];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
return toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
return YES;
}
#pragma mark - Actions
- (void)complete:(id)sender {
[_hud completeWithTitle:@"Finished"];
[self performSelector:@selector(pop:) withObject:nil afterDelay:0.7];
}
- (void)pop:(id)sender {
[_hud dismiss];
[self.navigationController popViewControllerAnimated:YES];
}
@end
//
// SCImageCollectionViewItem.h
// SSCatalog
//
// Created by Sam Soffes on 5/3/11.
// Copyright 2011 Sam Soffes. All rights reserved.
//
@interface SCImageCollectionViewItem : SSCollectionViewItem
@property (nonatomic, strong) NSURL *imageURL;
- (id)initWithReuseIdentifier:(NSString *)aReuseIdentifier;
@end
//
// SCImageCollectionViewItem.m
// SSCatalog
//
// Created by Sam Soffes on 5/3/11.
// Copyright 2011 Sam Soffes. All rights reserved.
//
#import "SCImageCollectionViewItem.h"
#import "UIImageView+AFNetworking.h"
@implementation SCImageCollectionViewItem
#pragma mark - Accessors
@synthesize imageURL = _imageURL;
- (void)setImageURL:(NSURL *)url {
_imageURL = url;
if (_imageURL) {
[self.imageView setImageWithURL:url placeholderImage:nil];
} else {
self.imageView.image = nil;
}
}
#pragma mark - Initializer
- (id)initWithReuseIdentifier:(NSString *)aReuseIdentifier {
if ((self = [super initWithStyle:SSCollectionViewItemStyleImage reuseIdentifier:aReuseIdentifier])) {
self.imageView.backgroundColor = [UIColor colorWithWhite:0.95f alpha:1.0f];
}
return self;
}
- (void)prepareForReuse {
[super prepareForReuse];
self.imageURL = nil;
}
@end
//
// SCLineViewDemoViewController.h
// SSCatalog
//
// Created by Sam Soffes on 4/19/10.
// Copyright 2010 Sam Soffes, Inc. All rights reserved.
//
@interface SCLineViewDemoViewController : UIViewController
+ (NSString *)title;
@end
//
// SCLineViewDemoViewController.m
// SSCatalog
//
// Created by Sam Soffes on 4/19/10.
// Copyright 2010 Sam Soffes, Inc. All rights reserved.
//
#import "SCLineViewDemoViewController.h"
@implementation SCLineViewDemoViewController
#pragma mark - Class Methods
+ (NSString *)title {
return @"Line View";
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = [[self class] title];
self.view.backgroundColor = [UIColor colorWithRed:0.851f green:0.859f blue:0.882f alpha:1.0f];
SSLineView *lineView1 = [[SSLineView alloc] initWithFrame:CGRectMake(20.0f, 20.0f, 280.0f, 2.0f)];
[self.view addSubview:lineView1];
SSLineView *lineView2 = [[SSLineView alloc] initWithFrame:CGRectMake(20.0f, 42.0f, 280.0f, 2.0f)];
lineView2.lineColor = [UIColor blueColor];
[self.view addSubview:lineView2];
SSLineView *lineView3 = [[SSLineView alloc] initWithFrame:CGRectMake(20.0f, 64.0f, 280.0f, 2.0f)];
lineView3.lineColor = [UIColor orangeColor];
lineView3.dashLengths = [NSArray arrayWithObjects:[NSNumber numberWithFloat:5.0f], [NSNumber numberWithFloat:2.0f], nil];
[self.view addSubview:lineView3];
SSLineView *lineView4 = [[SSLineView alloc] initWithFrame:CGRectMake(20.0f, 86.0f, 280.0f, 2.0f)];
lineView4.lineColor = [UIColor greenColor];
lineView4.dashLengths = [NSArray arrayWithObjects:[NSNumber numberWithFloat:2.0f], [NSNumber numberWithFloat:2.0f], nil];
[self.view addSubview:lineView4];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
return toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
return YES;
}
@end
//
// SCLoadingViewDemoViewController.h
// SSCatalog
//
// Created by Sam Soffes on 11/15/10.
// Copyright 2010 Sam Soffes. All rights reserved.
//
@interface SCLoadingViewDemoViewController : UIViewController
+ (NSString *)title;
@end
//
// SCLoadingViewDemoViewController.m
// SSCatalog
//
// Created by Sam Soffes on 11/15/10.
// Copyright 2010 Sam Soffes. All rights reserved.
//
#import "SCLoadingViewDemoViewController.h"
@implementation SCLoadingViewDemoViewController
#pragma mark - Class Methods
+ (NSString *)title {
return @"Loading View";
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = [[self class] title];
self.view.backgroundColor = [UIColor colorWithRed:0.851f green:0.859f blue:0.882f alpha:1.0f];
CGSize size = self.view.frame.size;
SSLoadingView *loadingView = [[SSLoadingView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, size.width, size.height)];
[self.view addSubview:loadingView];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
return toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
return YES;
}
@end
//
// SCPickerDemoViewController.h
// SSCatalog
//
// Created by Sam Soffes on 10/9/09.
// Copyright 2009 Sam Soffes, Inc. All rights reserved.
//
@interface SCPickerDemoViewController : UITableViewController
@property (nonatomic, strong) NSString *selectedAbbreviation;
+ (NSString *)title;
@end
//
// SCPickerDemoViewController.m
// SSCatalog
//
// Created by Sam Soffes on 10/9/09.
// Copyright 2009 Sam Soffes, Inc. All rights reserved.
//
#import "SCPickerDemoViewController.h"
#import "SCPickerDetailViewController.h"
@implementation SCPickerDemoViewController
#pragma mark - Accessors
@synthesize selectedAbbreviation = _selectedAbbreviation;
#pragma mark - Class Methods
+ (NSString *)title {
return @"Settings Picker";
}
#pragma mark - NSObject
- (id)init {
return self = [super initWithStyle:UITableViewStyleGrouped];
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = [[self class] title];
self.selectedAbbreviation = [[NSTimeZone defaultTimeZone] abbreviation];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.tableView reloadData];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
return toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
return YES;
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = @"Picker Value";
cell.detailTextLabel.text = [[NSTimeZone timeZoneWithAbbreviation:self.selectedAbbreviation] name];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
SCPickerDetailViewController *viewController = [[SCPickerDetailViewController alloc] initWithStyle:UITableViewStyleGrouped];
viewController.selectedKey = self.selectedAbbreviation;
[self.navigationController pushViewController:viewController animated:YES];
}
@end
//
// SCPickerDetailViewController.h
// SSCatalog
//
// Created by Sam Soffes on 10/9/09.
// Copyright 2009 Sam Soffes, Inc. All rights reserved.
//
@interface SCPickerDetailViewController : SSPickerViewController
@end
//
// SCPieProgressViewDemoViewController.h
// SSCatalog
//
// Created by Sam Soffes on 4/22/10.
// Copyright 2010 Sam Soffes, Inc. All rights reserved.
//
@interface SCPieProgressViewDemoViewController : UIViewController
+ (NSString *)title;
- (void)incrementProgress:(NSTimer *)timer;
@end
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment