ios - Swift: Thread 1 signal SIGABRT in class AppDelegate: UIResponder, UIApplicationDelegate -
i'm following tutorial , every time click button error in appdelegate.swift says thread 1 signal sigabrt.
import uikit @uiapplicationmain class appdelegate: uiresponder, uiapplicationdelegate { //thread 1 signal sigabrt
here's screenshot of storyboard.
i have looked on , answers refer iboutlet
connection doesn't exist can see in screenshot connections don't know problem is.
here's viewcontroller.swift code: import uikit
class viewcontroller: uiviewcontroller {
@iboutlet weak var input: uitextfield! @iboutlet weak var label: uilabel! @ibaction func button(_ sender: uibutton) { label.text = input.text userdefaults.standard.set(input, forkey: "myname") input.text = " " } override func viewdidload() { super.viewdidload() } override func didreceivememorywarning() { super.didreceivememorywarning() } override func viewdidappear(_ animated: bool) { if let x = userdefaults.standard.object(forkey: "myname") as? string{ label.text = x } }
}
here's complete error message when click button: 2017-08-20 23:29:09.155350+0800 asd[2297:997880] [layoutconstraints] unable simultaneously satisfy constraints. @ least 1 of constraints in following list 1 don't want. try this: (1) @ each constraint , try figure out don't expect; (2) find code added unwanted constraint or constraints , fix it. ( "<_uilayoutsupportconstraint:0x608000284d30 _uilayoutguide:0x7fc28340be50.height == 20 (active)>", "<_uilayoutsupportconstraint:0x608000283980 v:|-(0)-[_uilayoutguide:0x7fc28340be50] (active, names: '|':uiview:0x7fc28340b780 )>", "<_uilayoutsupportconstraint:0x608000284dd0 _uilayoutguide:0x7fc28340c420.height == 0 (active)>", "<_uilayoutsupportconstraint:0x608000284d80 _uilayoutguide:0x7fc28340c420.bottom == uiview:0x7fc28340b780.bottom (active)>", "", "", "", "", "", "", "", "" )
will attempt recover breaking constraint
make symbolic breakpoint @ uiviewalertforunsatisfiableconstraints catch in debugger. methods in uiconstraintbasedlayoutdebugging category on uiview listed in may helpful. 2017-08-20 23:29:11.137163+0800 asd[2297:997880] [mc] system group container systemgroup.com.apple.configurationprofiles path /users/myeongjeon/library/developer/coresimulator/devices/200d40a8-efd4-4fe9-8e13-37c2e7d86ba6/data/containers/shared/systemgroup/systemgroup.com.apple.configurationprofiles 2017-08-20 23:29:11.137610+0800 asd[2297:997880] [mc] reading private effective user settings. 2017-08-20 23:29:15.719443+0800 asd[2297:997880] [user defaults] attempt set non-property-list object ; layer = > nsuserdefaults/cfpreferences value key myname 2017-08-20 23:29:15.723 asd[2297:997880] * terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'attempt insert non-property list object ; layer = > key myname' * first throw call stack: ( 0 corefoundation 0x0000000103725b0b exceptionpreprocess + 171 1 libobjc.a.dylib 0x000000010318a141 objc_exception_throw + 48 2 corefoundation 0x000000010378e625 +[nsexception raise:format:] + 197 3 corefoundation 0x0000000103678729 _cfprefsvalidatevalueforkey + 249 4 corefoundation 0x00000001036e5afc -[cfprefsplistsource sendmessagesettingvalue:forkey:] + 572 5 corefoundation 0x000000010378fdaa -[cfprefsplistsource alreadylocked_setvalues:forkeys:count:] + 794 6 corefoundation 0x000000010374cc58 -[cfprefssource setvalues:forkeys:count:removevaluesforkeys:count:] + 264 7 corefoundation 0x0000000103678620 -[cfprefssource setvalues:forkeys:count:] + 32 8 corefoundation 0x0000000103786af6 -[cfprefssearchlistsource alreadylocked_setvalues:forkeys:count:] + 454 9 corefoundation 0x000000010374cc58 -[cfprefssource setvalues:forkeys:count:removevaluesforkeys:count:] + 264 10 corefoundation 0x0000000103678620 -[cfprefssource setvalues:forkeys:count:] + 32 11 corefoundation 0x00000001036bbfe9 -[cfprefssource setvalue:forkey:] + 57 12 corefoundation 0x0000000103788a4f __108-[_cfxpreferences(searchlistadditions) withsearchlistforidentifier:container:cloudconfigurationurl:perform:]_block_invoke + 319 13 corefoundation 0x000000010378824d normalizequintuplet + 317 14 corefoundation 0x0000000103788909 -[_cfxpreferences(searchlistadditions) withsearchlistforidentifier:container:cloudconfigurationurl:perform:] + 105 15 corefoundation 0x0000000103772c15 -[_cfxpreferences setvalue:forkey:appidentifier:container:configurationurl:] + 261 16 corefoundation 0x00000001036bbf34 _cfpreferencessetappvaluewithcontainer + 68 17 foundation 0x0000000102c89790 -[nsuserdefaults(nsuserdefaults) setobject:forkey:] + 55 18 asd 0x0000000102bafc51 tfc3asd14viewcontroller6buttonfcso8uibuttont + 1073 19 asd 0x0000000102baff6a ttofc3asd14viewcontroller6buttonfcso8uibuttont + 58 20 uikit 0x0000000103b4ad82 -[uiapplication sendaction:to:from:forevent:] + 83 21 uikit 0x0000000103ccf5ac -[uicontrol sendaction:to:forevent:] + 67 22 uikit 0x0000000103ccf8c7 -[uicontrol _sendactionsforevents:withevent:] + 450 23 uikit 0x0000000103cce802 -[uicontrol touchesended:withevent:] + 618 24 uikit 0x0000000103bb87ea -[uiwindow _sendtouchesforevent:] + 2707 25 uikit 0x0000000103bb9f00 -[uiwindow sendevent:] + 4114 26 uikit 0x0000000103b66a84 -[uiapplication sendevent:] + 352 27 uikit 0x000000010434a5d4 __dispatchpreprocessedeventfromeventqueue + 2926 28 uikit 0x0000000104342532 __handleeventqueue + 1122 29 corefoundation 0x00000001036cbc01 __cfrunloop_is_calling_out_to_a_source0_perform_function + 17 30 corefoundation 0x00000001036b10cf __cfrunloopdosources0 + 527 31 corefoundation 0x00000001036b05ff __cfrunlooprun + 911 32 corefoundation 0x00000001036b0016 cfrunlooprunspecific + 406 33 graphicsservices 0x0000000107d05a24 gseventrunmodal + 62 34 uikit 0x0000000103b49134 uiapplicationmain + 159 35 asd 0x0000000102bb1927 main + 55 36 libdyld.dylib 0x0000000106d9a65d start + 1 ) libc++abi.dylib: terminating uncaught exception of type nsexception
what's critically wrong code here:
@iboutlet weak var input: uitextfield! @ibaction func button(_ sender: uibutton) { label.text = input.text userdefaults.standard.set(input, forkey: "myname") input.text = " " }
you trying save input
standard userdefaults
, input
uitextfield
. cannot save uitextfield
userdefaults
.
maybe want this:
@ibaction func button(_ sender: uibutton) { label.text = input.text userdefaults.standard.set(input.text ?? "", forkey: "myname") input.text = " " }
the important part in debug output:
terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'attempt insert non-property list object ; layer = > key myname'
it saying code trying set invalid value key myname
.
messages constraints suggests code , storyboard settings may need fixed, not cause of crash.
Comments
Post a Comment