草庐IT

my_member

全部标签

ios - cellForRow(在 : indexPath) returns nil and crashes my swift app

在我的swift应用程序中,我在UITableView中显示单元格,前10个单元格包含一张照片。我决定为每个单元格添加视差效果,这样当用户上下滚动表格时-图像会改变它的偏移量。这是我从我的网络服务中获取数据并将其最初添加到TableView的方式:funcmakePostQueryForFetchingData(_parameters:[String:AnyObject],url:String,type:String){Alamofire.request(url,method:.post,parameters:(parameters),encoding:JSONEncoding.def

swift - C 中的 offsetof(struct, member) 在 Swift 中的等价物是什么?

这是Swift中的一个结构体:structA{varxvaryvarz}我应该怎么做才能得到结构A中y的偏移量,就像C中的offsetof(A,y)一样?谢谢:) 最佳答案 MemoryLayout.offset(of:)是在Swift4.2中添加的,实现了SE-0210Addanoffset(of:)methodtoMemoryLayout例子:structA{varx:Int8vary:Int16varz:Int64}MemoryLayout.offset(of:\A.x)//0MemoryLayout.offset(of:\A

swift - '(key : AnyObject, value: AnyObject )' does not have a member named ' 下标'

我有一个类似于thisquestion的问题,但那里的答案对我没有帮助。我有这些代码行:varid=item["id"]as?String??""varname=item["name"]as?String??""varpic=item["pic"]as?String??""对我来说,这些代码行几乎是一样的。对于Xcode,这是另一回事。第一行没问题。后两行生成此错误:'(key:AnyObject,value:AnyObject)'doesnothaveamembernamed'subscript'这里为大家提供更多背景信息:classfuncgetFromJson(json:NSDi

ios - 找不到成员(member)标志(快速,解析)

if(PFUser.currentUser()==nil){self.loginViewController.fields=PFLogInFields.UsernameAndPassword|PFLogInFields.LogInButton|PFLogInFields.SignUpButton|PFLogInFields.PasswordForgotten|PFLogInFields.DismissButtonvarlogInLogoTitle=UILabel()logInLogoTitle.text="Test"self.logInViewController.logInView.

php - swift 错误 : Error Domain=NSCocoaErrorDomain Code=3840 "Problems with my Login Controller "

这是我的代码,我无法编译它。我正在尝试登录到我的服务器,但它不允许我这样做抱歉,我是编程新手,我研究过stackoverflow,关于这个错误,我只能解析字典或数组。但我通过复制我的JSON响应进行了搜索,但它不起作用。任何建议都会有帮助!!importUIKitclassLogin:UIViewController{@IBOutletvarUsername:UITextField!@IBOutletvarPassword:UITextField!@IBActionfuncLogin(sender:UIButton){letusername=Username.textletpasswo

core-data - 核心数据错误 : 'AnyObject' does not have a member named 'Generator'

我无法弄清楚这里出了什么问题。代码只是将username和password添加到实体“Users”,然后检索它。代码运行良好,直到我在其中添加了一个for循环。我什至尝试将AnyObject转换为NSManagedObject(据我所知这不是必需的)代码:importUIKitimportCoreDataclassViewController:UIViewController{overridefuncviewDidLoad(){super.viewDidLoad()//Doanyadditionalsetupafterloadingtheview,typicallyfromanib.v

swift - Codable - arrayPropety [AnyObject] : Reference to member 'data' cannot be resolved without a contextual type

设置Codable类。AnyObjects数组产生编译错误:Referencetomember'data'cannotberesolvedwithoutacontextualtypeclassClassA:NSObject,Codable{//MARK:-Propertieslettitle:Stringletdata:[T]//dataisanarrayofeitherCodableobjectsofClassBorClassC.//MARK:-KeyesprivateenumCodingKeys:String,CodingKey{casetitlecasedata}required

ios - AVAudioSession : Some Bluetooth devices are not working properly on my App

我正在使用AVAudioSession开发一个快速的音频/视频和文本聊天iOS应用程序。每当我选择使用某些蓝牙设备时,设备上播放的声音不是App音频流。每当发送/接收消息时,它们只播放文本聊天库发送的系统声音。它不会在所有蓝牙设备上发生,在其中一些设备上一切正常。在内置麦克风和扬声器上,该应用程序也能正常工作。以下是我类用于管理设备的最重要的方法:classMyAudioSession{privatevarmAudioSession:AVAudioSession;init!(){self.mAudioSession=AVAudioSession.sharedInstance();do{

ios - swift 3.0 : Value of type 'IndexSet' has no member 'enumerateIndexesUsingBlock'

接收“IndexSet”类型的值在enumerateIndexesUsingBlock处没有成员“enumerateIndexesUsingBlock”错误。/**Extensionforcreatingindexpathsfromanindexset*/extensionIndexSet{/**-parametersection:ThesectionforthecreatedNSIndexPaths-return:AnarraywithNSIndexPaths*/funcbs_indexPathsForSection(_section:Int)->[IndexPath]{varind

enums - swift : 'Rank? does not have a member named ' simpleDescription'?

我在下面的代码中不断收到错误:letrank1desc=rank1Conv.simpleDescription();letrank2desc=rank2Conv.simpleDescription();声称“等级?”没有名为“simpleDescription”的成员。我觉得这很奇怪,因为我根据Apple的教程编写了这段代码,并且没有像Rank一样在任何地方实现和可选?暗示我有。我很想知道为什么它会给我这个错误,如果确实存在的话,可选的是从哪里来的。非常感谢!这是我的代码:enumRank:Int{caseAce=1;caseTwo=2,Three=3,Four=4,Five=5,Si