Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to Swift 2.2 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion Core Image Explorer.xcodeproj/project.pbxproj 100644 → 100755
Expand Up @@ -146,7 +146,8 @@
8319B4471A5CC7EB0040418B /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0620;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0730;
ORGANIZATIONNAME = objc.io;
TargetAttributes = {
8319B44E1A5CC7EB0040418B = {
Expand Down Expand Up @@ -245,6 +246,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -311,6 +313,7 @@
INFOPLIST_FILE = "Core Image Explorer/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.objc.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -322,6 +325,7 @@
INFOPLIST_FILE = "Core Image Explorer/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.objc.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand Down
Empty file modified Core Image Explorer/AppDelegate.swift 100644 → 100755
Empty file.
Empty file modified Core Image Explorer/Base.lproj/LaunchScreen.xib 100644 → 100755
Empty file.
Empty file modified Core Image Explorer/Base.lproj/Main.storyboard 100644 → 100755
Empty file.
20 changes: 10 additions & 10 deletions Core Image Explorer/FilterDetailViewController.swift 100644 → 100755
Expand Up @@ -20,7 +20,7 @@ class FilterDetailViewController: UIViewController, UINavigationControllerDelega

filter = CIFilter(name: filterName)

navigationItem.title = filter.attributes()![kCIAttributeFilterDisplayName] as? NSString
navigationItem.title = filter.attributes[kCIAttributeFilterDisplayName] as? String

addSubviews()
}
Expand All @@ -39,19 +39,19 @@ class FilterDetailViewController: UIViewController, UINavigationControllerDelega
}

func filterParameterDescriptors() -> [ScalarFilterParameter] {
var inputNames = (filter.inputKeys() as [String]).filter { (parameterName) -> Bool in
let inputNames = (filter.inputKeys as [String]).filter { (parameterName) -> Bool in
return (parameterName as String) != "inputImage"
}

let attributes = filter.attributes()!
let attributes = filter.attributes

return inputNames.map { (inputName: String) -> ScalarFilterParameter in
let attribute = attributes[inputName] as [String : AnyObject]
let attribute = attributes[inputName] as! [String : AnyObject]
// strip "input" from the start of the parameter name to make it more presentation-friendly
let displayName = inputName[advance(inputName.startIndex, 5)..<inputName.endIndex]
let minValue = attribute[kCIAttributeSliderMin] as Float
let maxValue = attribute[kCIAttributeSliderMax] as Float
let defaultValue = attribute[kCIAttributeDefault] as Float
let displayName = inputName[inputName.startIndex.advancedBy(5)..<inputName.endIndex]
let minValue = attribute[kCIAttributeSliderMin] as! Float
let maxValue = attribute[kCIAttributeSliderMax] as! Float
let defaultValue = attribute[kCIAttributeDefault] as! Float

return ScalarFilterParameter(name: displayName, key: inputName,
minimumValue: minValue, maximumValue: maxValue, currentValue: defaultValue)
Expand All @@ -65,11 +65,11 @@ class FilterDetailViewController: UIViewController, UINavigationControllerDelega
filteredImageView.contentMode = .ScaleAspectFit
filteredImageView.clipsToBounds = true
filteredImageView.backgroundColor = view.backgroundColor
filteredImageView.setTranslatesAutoresizingMaskIntoConstraints(false)
filteredImageView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(filteredImageView)

parameterAdjustmentView = ParameterAdjustmentView(frame: view.bounds, parameters: filterParameterDescriptors())
parameterAdjustmentView.setTranslatesAutoresizingMaskIntoConstraints(false)
parameterAdjustmentView.translatesAutoresizingMaskIntoConstraints = false
parameterAdjustmentView.setAdjustmentDelegate(filteredImageView)
view.addSubview(parameterAdjustmentView)
}
Expand Down
4 changes: 2 additions & 2 deletions Core Image Explorer/FilterListViewController.swift 100644 → 100755
Expand Up @@ -41,8 +41,8 @@ class FilterListViewController: UITableViewController {

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showDetail" {
if let indexPath = tableView.indexPathForSelectedRow() {
var controller = segue.destinationViewController as FilterDetailViewController
if let indexPath = tableView.indexPathForSelectedRow {
let controller = segue.destinationViewController as! FilterDetailViewController
controller.filterName = filters[indexPath.row].filterName
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
Expand Down
8 changes: 4 additions & 4 deletions Core Image Explorer/FilteredImageView.swift 100644 → 100755
Expand Up @@ -35,7 +35,7 @@ class FilteredImageView: GLKView, ParameterAdjustmentDelegate {
}

required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
super.init(coder: aDecoder)!
clipsToBounds = true
self.context = EAGLContext(API: .OpenGLES2)
ciContext = CIContext(EAGLContext: context)
Expand All @@ -45,13 +45,13 @@ class FilteredImageView: GLKView, ParameterAdjustmentDelegate {
if ciContext != nil && inputImage != nil && filter != nil {
let inputCIImage = CIImage(image: inputImage)
filter.setValue(inputCIImage, forKey: kCIInputImageKey)
if let outputImage = filter.outputImage {
if let _ = filter.outputImage {
clearBackground()

let inputBounds = inputCIImage.extent()
let inputBounds = inputCIImage!.extent
let drawableBounds = CGRect(x: 0, y: 0, width: self.drawableWidth, height: self.drawableHeight)
let targetBounds = imageBoundsForContentMode(inputBounds, toRect: drawableBounds)
ciContext.drawImage(filter.outputImage, inRect: targetBounds, fromRect: inputBounds)
ciContext.drawImage(filter.outputImage!, inRect: targetBounds, fromRect: inputBounds)
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions Core Image Explorer/Images.xcassets/AppIcon.appiconset/Contents.json 100644 → 100755
Expand Up @@ -63,6 +63,12 @@
"idiom" : "ipad",
"filename" : "Icon~ipad@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-83.5@2x.png",
"scale" : "2x"
}
],
"info" : {
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Core Image Explorer/Info.plist 100644 → 100755
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>io.objc.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
10 changes: 5 additions & 5 deletions Core Image Explorer/LabeledSliderView.swift 100644 → 100755
Expand Up @@ -33,25 +33,25 @@ class LabeledSliderView: UIView {
slider.minimumValue = parameter.minimumValue!
slider.maximumValue = parameter.maximumValue!
slider.value = parameter.currentValue
slider.setTranslatesAutoresizingMaskIntoConstraints(false)
slider.translatesAutoresizingMaskIntoConstraints = false
addSubview(slider)

slider.addTarget(self, action: "sliderTouchUpInside:", forControlEvents: .TouchUpInside)
slider.addTarget(self, action: "sliderValueDidChange:", forControlEvents: .ValueChanged)
slider.addTarget(self, action: #selector(LabeledSliderView.sliderTouchUpInside(_:)), forControlEvents: .TouchUpInside)
slider.addTarget(self, action: #selector(LabeledSliderView.sliderValueDidChange(_:)), forControlEvents: .ValueChanged)

descriptionLabel = UILabel(frame: frame)
descriptionLabel.font = UIFont.boldSystemFontOfSize(14)
descriptionLabel.textColor = UIColor(white: 0.9, alpha: 1.0)
descriptionLabel.text = parameter.name
descriptionLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
descriptionLabel.translatesAutoresizingMaskIntoConstraints = false
addSubview(descriptionLabel)

valueLabel = UILabel(frame: frame)
valueLabel.font = UIFont.systemFontOfSize(14)
valueLabel.textColor = UIColor(white: 0.9, alpha: 1.0)
valueLabel.textAlignment = .Right
valueLabel.text = slider.value.description
valueLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
valueLabel.translatesAutoresizingMaskIntoConstraints = false
addSubview(valueLabel)
}

Expand Down
2 changes: 1 addition & 1 deletion Core Image Explorer/ParameterAdjustmentView.swift 100644 → 100755
Expand Up @@ -46,7 +46,7 @@ class ParameterAdjustmentView: UIView {
let frame = CGRectMake(0, yOffset, bounds.size.width, kSliderHeight)

let sliderView = LabeledSliderView(frame: frame, parameter: param)
sliderView.setTranslatesAutoresizingMaskIntoConstraints(false)
sliderView.translatesAutoresizingMaskIntoConstraints = false
addSubview(sliderView)

sliderViews.append(sliderView)
Expand Down
2 changes: 1 addition & 1 deletion Core Image Explorer/PhotoFilterCollectionViewCell.swift 100644 → 100755
Expand Up @@ -21,7 +21,7 @@ class PhotoFilterCollectionViewCell: UICollectionViewCell {
}

required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
super.init(coder: aDecoder)!
addSubviews()
}

Expand Down
4 changes: 2 additions & 2 deletions Core Image Explorer/PhotoFilterViewController.swift 100644 → 100755
Expand Up @@ -30,7 +30,7 @@ class PhotoFilterViewController: UIViewController, UICollectionViewDataSource, U
super.viewDidLoad()

for descriptor in filterDescriptors {
filters.append(CIFilter(name: descriptor.filterName))
filters.append(CIFilter(name: descriptor.filterName)!)
}

filteredImageView.inputImage = UIImage(named: kSampleImageName)
Expand All @@ -51,7 +51,7 @@ class PhotoFilterViewController: UIViewController, UICollectionViewDataSource, U
}

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("PhotoFilterCell", forIndexPath: indexPath) as PhotoFilterCollectionViewCell
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("PhotoFilterCell", forIndexPath: indexPath) as! PhotoFilterCollectionViewCell
cell.filteredImageView.contentMode = .ScaleAspectFill
cell.filteredImageView.inputImage = filteredImageView.inputImage
cell.filteredImageView.filter = filters[indexPath.item]
Expand Down
Empty file modified Core Image Explorer/ScalarFilterParameter.swift 100644 → 100755
Empty file.
Empty file modified Core Image Explorer/duckling.jpg 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified LICENSE 100644 → 100755
Empty file.
Empty file modified README.md 100644 → 100755
Empty file.
Empty file modified screenshots/color-controls.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified screenshots/photo-filters.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.