Table "public.scoreboards"
Column | Type | Modifiers
----------------------+-----------------------------+----------------------------------------------------------
id | integer | not null default nextval('scoreboards_id_seq'::regclass)
name_of_scoreboard | character varying |
name_of_organization | character varying |
name_of_activity | character varying |
user_id | integer |
created_at | timestamp without time zone | not null
updated_at | timestamp without time zone | not null
states | character varying |
country | character varying |
cities | character varying |
Indexes:
"scoreboards_pkey" PRIMARY KEY, btree (id)
"index_scoreboards_on_user_id" btree (user_id)
"index_scoreboards_on_user_id_and_created_at" btree (user_id, created_at)
Foreign-key constraints:
"fk_rails_09668734c5" FOREIGN KEY (user_id) REFERENCES users(id)
Referenced by:
TABLE "comments" CONSTRAINT "fk_rails_5cb64542d4" FOREIGN KEY (scoreboard_id) REFERENCES scoreboards(id)
Table "public.users"
Column | Type | Modifiers
-------------------+-----------------------------+----------------------------------------------------
id | integer | not null default nextval('users_id_seq'::regclass)
name | character varying |
email | character varying |
created_at | timestamp without time zone | not null
updated_at | timestamp without time zone | not null
password_digest | character varying |
remember_digest | character varying |
admin | boolean | default false
activation_digest | character varying |
activated | boolean | default false
activated_at | timestamp without time zone |
reset_digest | character varying |
reset_sent_at | timestamp without time zone |
Indexes:
"users_pkey" PRIMARY KEY, btree (id)
"index_users_on_email" UNIQUE, btree (email)
Referenced by:
TABLE "scoreboards" CONSTRAINT "fk_rails_09668734c5" FOREIGN KEY (user_id) REFERENCES users(id)
:
handlerID数组已填充,但是当我检查时,它是空的。 :( 请帮忙 我已经更新了所有代码。
这是一个调用代码。我用按钮拨打每个基金
import UIKit
class Connecting {
let refHandler = Firebase(url: "https://-unique-link-.firebaseio.com/handlers")
var handlerID: [AnyObject] = []
func getHandlerStatus() {
refHandler.queryOrderedByChild("status").observeEventType(.ChildAdded, withBlock: { snapshot in
if let status = snapshot.value["status"] as? Int {
if status == 0 {
self.handlerID.append(snapshot.key)
print(self.handlerID)
} else {
//Do Nothing
}
}
})
}
func handlerIDReturn() -> NSArray {
print(handlerID)
return handlerID
}
}
答案 0 :(得分:1)
您只需要创建Connecting
的一个实例并使用它。目前,每次拨打Connecting()
都会给你一个新对象。
let connecting = Connecting()
@IBAction func callerButton(sender: AnyObject) {
connecting.getHandlerStatus()
}
@IBAction func button2nd(sender: AnyObject) {
print(connecting.handlerIDReturn())
}