简体   繁体   English

初始化器类型无法构造,因为它没有可访问的初始化器

[英]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 :) 我在标题中提到了上面的问题,此porgram用于IOS 8.2作为目标,但是当我在我的Xcode中使用它时,它显示错误,因为目标是8.0,请提前感谢:)

mine Code is Given Below and i need it for target 8.0 我的代码在下面给出,我需要它用于目标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 1-)在左侧面板上选择项目根目录

2-) In General -> Deployment Info window you can set your target. 2-)在常规->部署信息窗口中,您可以设置目标。 在此处输入图片说明

bro you have updated your Xcode and using the code with of previous IOS versions. 兄弟,您已经更新了Xcode,并将代码与以前的IOS版本一起使用。 you should search how to initialise these vars in 8.2 .. 您应该在8.2中搜索如何初始化这些变量。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法构造&#39;UITabBarDelegate&#39;,因为它没有可访问的初始化程序 - 'UITabBarDelegate' cannot be constructed because it has no accessible initializers 无法构造委托,因为它没有可访问的初始化程序? - Delegate cannot be constructed because it has no accessible initializers? 无法构造“ CLLocationManagerDelegate”,因为它没有可访问的初始化程序 - 'CLLocationManagerDelegate' cannot be constructed because it has no accessible initializers 无法构建&#39;DepartmentDataDelegate&#39;,因为它没有可访问的初始化程序 - 'DepartmentDataDelegate' cannot be constructed because it has no accessible initializers 枚举:“无法构造,因为它没有可访问的初始值设定项” - Enumeration: “cannot be constructed because it has no accessible initializers” 无法构造“任务”,因为它没有可访问的初始值设定项 - 'Task' cannot be constructed because it has no accessible initializers Swift:Enum&#39;无法构造,因为它没有可访问的初始值设定项&#39; - Swift : Enum 'cannot be constructed because it has no accessible initializers' 无法构建游戏场景,因为它没有可访问的初始化程序 - Game Scene cannot be constructed because it has not accessible initializers 错误:'结果<data, foursquareerror> ' 无法构造,因为它没有可访问的初始值设定项</data,> - Error: 'Result<Data, FourSquareError>' cannot be constructed because it has no accessible initializers Swift 错误:无法构造“Human”,因为它没有可访问的初始值设定项 - Swift Error: 'Human' cannot be constructed because it has no accessible initializers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM