我正在为MacOS制作简单的SQLite数据库,并使用来自this教程的信息,该教程适用于iOS。
当我实现这些代码行时,我收到错误“在nstextfield类型的对象上找不到属性文本”:
NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO CONTACTS
(name, address, phone) VALUES (\"%@\", \"%@\", \"%@\")",
name.text, address.text, phone.text];
如何为MacOS实现此功能?
答案 0 :(得分:1)
尝试使用NSTextField的stringValue
属性(NSTextField继承的NSControl):
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSControl_Class/Reference/Reference.html#//apple_ref/occ/cl/NSControl
NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO CONTACTS
(name, address, phone) VALUES (\"%@\", \"%@\", \"%@\")",
name.stringValue, address.stringValue, phone.stringValue];