-1

I am a newbie to programming but the problem is the the ViewController . I am using core graphics to create a shape accordingly. Error to display view controller to segue to display the page.

import UIKit

class ViewController: UIViewController,CustomViewDelegate {


    @IBOutlet weak var sliderSmile: UISlider!



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


        let defaults:NSUserDefaults = NSUserDefaults.standardUserDefaults()
        let x:CGFloat = CGFloat(defaults.floatForKey("currentImagePosX"))
        let y:CGFloat = CGFloat(defaults.floatForKey("currentImagePosY"))
        //make a point
        //get a ref to the view
        let view = self.view as! CustomView
        //the crucial line
        view.delegate = self

        view.defaultPos.x = x
        view.defaultPos.y = y





    }


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



    @IBAction func smileValueChanged(sender: UISlider) {

        let customView = self.view as! CustomView
        customView.setSmile = CGFloat (sender.value)

    }

}

Delegate


import Foundation
import UIKit

protocol CustomViewDelegate
{

    func upDateImagePosition(currentPos: CGPoint)

}

Error to display view controller to segue to display the page.

2016-05-19 03:15:30.050 Usmaan [20208:1816738] Unknown class _TtC7Usmaan_8Graphics in Interface Builder file.
2016-05-19 03:15:30.080 Usmaan [20208:1816738] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fcc0b7fbc80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key sliderSmile.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000109c5ee65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010bbc6deb objc_exception_throw + 48
    2   CoreFoundation                      0x0000000109c5eaa9 -[NSException raise] + 9
    3   Foundation                          0x000000010a24f9bb -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
    4   UIKit                               0x000000010a832320 -[UIViewController setValue:forKey:] + 88
    5   UIKit                               0x000000010aa60f41 -[UIRuntimeOutletConnection connect] + 109
    6   CoreFoundation                      0x0000000109b9f4a0 -[NSArray makeObjectsPerformSelector:] + 224
    7   UIKit                               0x000000010aa5f924 -[UINib instantiateWithOwner:options:] + 1864
    8   UIKit                               0x000000010a838eea -[UIViewController _loadViewFromNibNamed:bundle:] + 381
    9   UIKit                               0x000000010a839816 -[UIViewController loadView] + 178
    10  UIKit                               0x000000010a839b74 -[UIViewController loadViewIfRequired] + 138
    11  UIKit                               0x000000010a83ff4f -[UIViewController __viewWillAppear:] + 120
    12  UIKit                               0x000000010a86fe44 -[UINavigationController _startCustomTransition:] + 1203
    13  UIKit                               0x000000010a88023f -[UINavigationController _startDeferredTransitionIfNeeded:] + 712
    14  UIKit                               0x000000010a8813af -[UINavigationController __viewWillLayoutSubviews] + 57
    15  UIKit                               0x000000010aa27ff7 -[UILayoutContainerView layoutSubviews] + 248
    16  UIKit                               0x000000010a75a4a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
    17  QuartzCore                          0x000000010f73359a -[CALayer layoutSublayers] + 146
    18  QuartzCore                          0x000000010f727e70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
    19  QuartzCore                          0x000000010f727cee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    20  QuartzCore                          0x000000010f71c475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
    21  QuartzCore                          0x000000010f749c0a _ZN2CA11Transaction6commitEv + 486
    22  UIKit                               0x000000010a69df7c _UIApplicationHandleEventQueue + 7329
    23  CoreFoundation                      0x0000000109b8aa31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    24  CoreFoundation                      0x0000000109b8095c __CFRunLoopDoSources0 + 556
    25  CoreFoundation                      0x0000000109b7fe13 __CFRunLoopRun + 867
    26  CoreFoundation                      0x0000000109b7f828 CFRunLoopRunSpecific + 488
    27  GraphicsServices                    0x000000010f1e8ad2 GSEventRunModal + 161
    28  UIKit                               0x000000010a6a3610 UIApplicationMain + 171
    29  Usmaan                              0x00000001096a50dd main + 109
    30  libdyld.dylib                       0x000000010c6d892d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

1 Answers1

0

You need to implement upDateImagePosition in your View Controller. Otherwise, the controller doesn't conform to the methods and properties set out in the protocol. See documentation on protocols for more details: Apple docs

brimstone
  • 3,370
  • 3
  • 28
  • 49
  • thank you. Also have a problem with Exception Error to display core graphics. Segue onto the ViewController screen. The application delegate displays a error – Usmaan Gill May 19 '16 at 02:17
  • @UsmaanGill http://stackoverflow.com/questions/3088059/what-does-this-mean-nsunknownkeyexception-reasonthis-class-is-not-key-valu – brimstone May 19 '16 at 02:19