我需要生成一个随机数.
看起来arc4random功能不再存在以及arc4random_uniform功能.
我的选择是arc4random_stir(), arc4random_buf(UnsafeMutablePointer<Void>, Int)和 arc4random_addrandom(UnsafeMutablePointer<UInt8>, Int32).
我找不到关于函数的任何文档,并且头文件中没有注释给出提示.
我有一系列的键导致我的社交网络的帖子对象像/ posts/id /(发布信息)
当我加载帖子时,我使用observeSingleEventOfType(.Value)方法加载/发布/ 0然后/ posts/1等.
我使用lazyTableView一次加载30并且速度很慢.有没有什么方法可以使用其中一种查询方法或其他方法使其更快,即使我必须重构我的JSON树中的数据.
我来自Parse重新实现我的应用程序,到目前为止,经验非常好.只有这一点我有点坚持.在此先感谢您的帮助!
编辑:
func loadNext(i: Int) {
// check if exhists
let ideaPostsRef = Firebase(url: "https://APPURL")
ideaPostsRef.childByAppendingPath(i.description).observeSingleEventOfType(.Value, withBlock: {
(snapshot) in
if i % 29 == 0 && i != 0 && !self.hitNull { return }
// false if nil
// true if not nil
if !(snapshot.value is NSNull) {
let postJSON = snapshot.value as! [String: AnyObject]
print("GOT VALID \(postJSON)")
let post = IdeaPost(message: postJSON["message"] as! String, byUser: postJSON["user"] as! String, withId: i.description)
post.upvotes …Run Code Online (Sandbox Code Playgroud) 我正在制作一个国际象棋游戏,并希望制作一个标准的接口/协议.Python没有语言中的那些,所以我应该使用什么?我读了一些关于工厂的内容,但我不确定他们会如何提供帮助.提前致谢!
我有一个圆形的视图,并通过以下代码覆盖touchesBegan(touches:, withEvent:)和旋转touchesMoved(touches:, withEvent:).
var deltaAngle = CGFloat(0)
var startTransform: CGAffineTransform?
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?)
{
let touchPoint = touches.first!.locationInView(view)
let dx = touchPoint.x - view.center.x
let dy = touchPoint.y - view.center.y
deltaAngle = atan2(dy, dx)
startTransform = arrowPickerView.transform
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?)
{
let touchPoint = touches.first!.locationInView(view)
let dx = touchPoint.x - view.center.x
let dy = touchPoint.y - view.center.y
let angle = atan2(dy, dx)
let angleDifference = deltaAngle - …Run Code Online (Sandbox Code Playgroud) 我在ViewController中使用以下代码创建了一个全新的mac app项目.
import Cocoa
import WebKit
class ViewController: NSViewController {
var loginWebView: WKWebView!
override func viewDidLoad()
{
super.viewDidLoad()
self.loginWebView = WKWebView(frame: self.view.frame)
self.view.addSubview(loginWebView)
let urlReq = URLRequest(url: URL(string: "https://apple.com/")!)
self.loginWebView.load(urlReq)
// Do any additional setup after loading the view.
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,当我启动应用程序时,Web视图未加载网站.为什么是这样?我已经在iOS上开发多年了,我刚刚开始使用macOS.
编辑:更新加载本地文件也无法正常工作
self.loginWebView.loadFileURL(fileURL, allowingReadAccessTo: dirURL)
Run Code Online (Sandbox Code Playgroud) 在 iOS 8 中,为了获得 Helvetica Neue 的瘦变体,以下代码将起作用
UIFont.systemFontOfSize(50, weight: UIFontWeightThin)
Run Code Online (Sandbox Code Playgroud)
在 iOS 9 系统字体更改为 San Francisco,所以我不能再这样做了。我绝对必须在这个应用程序中使用 Helvetia 并且无法弄清楚如何设置字体粗细。这是我目前使用的代码。
timeSelectedLabel.font = UIFont(name: "Helvetica Neue", size: CGFloat(50))
Run Code Online (Sandbox Code Playgroud)
我知道有一个接受 UIFontDescriptor 的构造函数。虽然不确定如何使用它。任何想法表示赞赏!
注意:在将其标记为重复之前,请了解仅有的 2 个帖子要么未答复,要么当前不起作用。
ios ×3
swift ×3
arc4random ×1
firebase ×1
interface ×1
macos ×1
protocols ×1
python ×1
touch-event ×1
transform ×1
trigonometry ×1
uifont ×1
wkwebview ×1