iOSでtopに戻る

ViewController.swift

class ViewController: UIViewController {
    
    @IBAction func unwindToTop(seque: UIStoryboardSegue){
        
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

Main.storyboard
control でexitにもっていき、unwindToTopを設定する

Gif class

class Gif {
	let url: NSURL
	let videoURL: NSURL
	let caption: String?
	let gifImage: UIImage?
	var gifData: NSData?

	init(url:NSURL, videoURL: NSURL, caption: String?){

		self.url = url
		self.videoURL = videoURL
		self.caption = caption
		self.gifImage = UIImage.gifWithURL(url.absoluteString)!
		self.gifData = nil
	}

	init(name: String){
		self.gifImage = UIImage.gifWithName(name)
	}
}
#import <UIKit/UIKit.h>
#import "Gif.h"

@interface GifEditorViewController : UIViewController<UITextFeildDelegate>

@property (nonatomic) Gif *gif;
@property (weak, nonatomic) IBOutlet UIImageView *gifImageView;

@end

UITextFieldDelegate Methods

func textFieldDidBeginEditing(textField: UITextField){
	textField.placeholder = ""
}

func textFieldShoudReturn(textField: UITextField) -> Bool {
	textField.resignFirstResponder()
	return true
}

Research

Brain Storm -> Create a Skelelon UI -> Research APIs and Libraries
Choose an Idea -> Create a paper prototype -> get user feedback -> Build APP

Developing nice graphic design
Building the user interface with UIKit
Downloading data from an API
Persisting the data
Working through problems and bug to get the app working well.
Posting the app to the App Store

-Create a Paper Prototype

Breakpoints and Visual Tools

override func viewDidLoad(){
	super.viewDidLoad()
	let singleTapRecognizer = UITapGestureRecognizer
	(target: self, action: "handleSingleTap:")
	view.addGestureRecognizer(singleTapRecognizer)
}
@IBAction func popToMasterView(){
	self.navigationController?.popToRootViewControllerAnimated(true)
}

LLDB and Breakpoint Actions

override func motionEnded(motion: UIEventSubtype,
	withEvent event: UIEvent){
		if motion == .MotionShake
		{
			disperseBugsAnimation()
		}
	}
	func handleSignleTap(recognizer:
		UITapGestureRecognizer){
		addBugToView()
		addButToView()
		}

thread backtrace all

Apple’s LLDB Quick Start Guide
https://developer.apple.com/library/content/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-command-examples.html#//apple_ref/doc/uid/TP40012917-CH3-SW1

The Debug Bar

func addBugToView(){
if bugs.count < maxBugs { let newBug = bugFactory.createBug() bug.append(newBug) moveBugsAnimation() } } func emptyBugsFromView(){ for bug in self.bugs { bug.removeFromSuperview() } self.bugs.removeAll(keepCapacity: true) } [/code] Getting Help with Bugs Stack Overflow
-be specific as possible
-provides steps leading to the problems
– can use text, code, images, gifts…

Warnings and Errors

warnings – issues identified by the compiler that MIGHT CAUSE PROBLEMS or have UNINTENDED SIDE-EFFECTS on running application
errors – issues identified by the compiler that MUST BE FIXED prior to running application

logic error:a bug in a program that causes it to operate incorrectly, but not to terminate abnormally
runtime errors: issues that occur while your application is running – these can be logic errors or errors that cause application to crash
software bug: an error, flaw, failure, or fault in a computer program or system that causes it to produce an incorrect or unexpected result, or to behave in unintended ways
static errors: issues identified by the compiler that must be fixed prior to running application
warning: issues that might cause problems or have unintended side-effects on running application

Reproduce the problem -> Gather debug information -> what is the value of a variable? what kind of error?
logs, program state, …

=> Form a Hypothesis

print debugging
-only use print statements to debug

extension PrintBugViewController {
	override func canBecomeFirstResponder() -> Bool {
		return true
	}
	override func motionEnded(motion: UIEventSubtype,
	withEvent event: UIEvent){
		if motion == .MotionShake {
			disperseBugsAnimation()
		}
	}
	func handleSingTap(recognizer: UITapGestureRecognizer) {
		addBugToView()
	}
}

func addBugToView(){
println(self)
if bugs.count < maxBugs { let newBug = bugFactory.createBug() bugs.append(newBug) view.addSubview(newBug) moveBugsAnimation() } println(self) } func emptyBugsFormView(){ for bug in self.bugs { bug.removeFromSuperview() } } extension PrintBugViewController : Printable, DebugPrintable { override var description: String { return "PrintBugViewController contains \(bugs.count) bugs\n" } }[/code]