简体   繁体   中英

Initializers Type Cannot be constructed because it has no accessible initializer

i am having the above problem as mention in title this porgram is for IOS 8.2 as target but when i use it in mine Xcode it shows the Error As there target is 8.0 please thanks in Advance :)

mine Code is Given Below and i need it for target 8.0

import UIKit
import MapKit
import CoreLocation

let kGeotificationLatitudeKey = "latitude"
let kGeotificationLongitudeKey = "longitude"
let kGeotificationRadiusKey = "radius"
let kGeotificationIdentifierKey = "identifier"
let kGeotificationNoteKey = "note"
let kGeotificationEventTypeKey = "eventType"

enum EventType: Int {
 case OnEntry = 0
 case OnExit = 1
}

class Geotification: NSObject, NSCoding, MKAnnotation {
 var coordinate: CLLocationCoordinate2D
 var radius: CLLocationDistance
 var identifier: String
 var note: String
 var eventType: EventType

 var title: String {
  if note.isEmpty {
   return "No Note"
  }
  return note
 }

 var subtitle: String {
  var eventTypeString = eventType == .OnEntry ? "On Entry" : "On Exit"
  return "Radius: \(radius)m - \(eventTypeString)"
 }

 init(coordinate: CLLocationCoordinate2D, radius: CLLocationDistance,             identifier: String, note: String, eventType: EventType) {
  self.coordinate = coordinate
  self.radius = radius
  self.identifier = identifier
  self.note = note
  self.eventType = eventType
 }

 // MARK: NSCoding

 required init(coder decoder: NSCoder) {
  let latitude = decoder.decodeDoubleForKey(kGeotificationLatitudeKey)
  let longitude = decoder.decodeDoubleForKey(kGeotificationLongitudeKey)
  coordinate = CLLocationCoordinate2D(latitude: latitude, longitude:       longitude)
  radius = decoder.decodeDoubleForKey(kGeotificationRadiusKey)
  identifier = decoder.decodeObjectForKey(kGeotificationIdentifierKey) as  String
  note = decoder.decodeObjectForKey(kGeotificationNoteKey) as String
  eventType =         EventType(decoder.decodeIntegerForKey(kGeotificationEventTypeKey))

 }

 func encodeWithCoder(coder: NSCoder) {
  coder.encodeDouble(coordinate.latitude, forKey: kGeotificationLatitudeKey)
  coder.encodeDouble(coordinate.longitude, forKey: kGeotificationLongitudeKey)
    coder.encodeDouble(radius, forKey: kGeotificationRadiusKey)
    coder.encodeObject(identifier, forKey: kGeotificationIdentifierKey)
    coder.encodeObject(note, forKey: kGeotificationNoteKey)
    coder.encodeInt(Int32(eventType.rawValue, forKey:     kGeotificationEventTypeKey))
  }
}

1-) Choose your project root on the left panel

2-) In General -> Deployment Info window you can set your target. 在此处输入图片说明

bro you have updated your Xcode and using the code with of previous IOS versions. you should search how to initialise these vars in 8.2 ..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM