小编Shr*_*ada的帖子

在运行时删除所有领域对象

在iOS上,我们可以轻松调用realm.deleteAllObjects();以删除Realm数据库中的所有对象.

我们如何在Android中实现同样的目标?

java realm

13
推荐指数
3
解决办法
1万
查看次数

什么是ViewController.swift(接口)文件 - 在Counterparts中

我刚刚注意到,ViewController.swift (Interface)当我创建第一个ViewController时,Xcode会自动创建一个名为的文件.

Swift中的类是否需要与Objective-C中的接口相同,并且是由Xcode在幕后创建的?

有人可以这么善良并解释这个文件的目的是什么?

ViewController.swift(接口)

import UIKit

internal class ViewController : UIViewController {

    override internal func viewDidLoad()

    override internal func didReceiveMemoryWarning()
}
Run Code Online (Sandbox Code Playgroud)

xcode uiviewcontroller ios swift

10
推荐指数
1
解决办法
4106
查看次数

需要Swift中Memoize实现的详细说明(WWDC 14,会话404)

Dave Abrahams提供了一个非常有趣的memoize版本(WWDC 2014 Session 404:Advanced Swift):

func Memoize<T:Hashable, U> (body: (T -> U, T ) -> U ) -> (T) -> U {

      var memo = Dictionary <T, U> ()

      var result: (T -> U)!

      result = { x in
            if let q = memo[x] { return q }
            let r = body(result, x)
            memo[x] = r
            return r
      }

      return result
}

let factorial = Memoize { (factorial, x) in
                x == 0 ? 1 : x …
Run Code Online (Sandbox Code Playgroud)

swift

8
推荐指数
1
解决办法
1031
查看次数

Xcode 中的文件不起作用(红色名称)

我重命名了我的应用程序文件夹以尝试更改应用程序的名称,因为它在项目导航器中不起作用,当我这样做时,所有文件都显示为红色。我试图通过将文件重命名回原来的样子来修复它,但它仍然不起作用。

任何帮助将不胜感激。

保管箱链接:https ://www.dropbox.com/s/omvo0saff0z9ncc/TicketekApp%202.zip ? dl =0

ios xcode7

7
推荐指数
2
解决办法
7339
查看次数

删除Realm中的列

我正在检查迁移文档,但是,我不确定我是否忽略了或者没有说明,但我注意到文档只解释了如何添加列,如果我想删除列怎么办?

realm swift realm-migration

6
推荐指数
2
解决办法
3021
查看次数

git 错误:内存不足,malloc 失败(尝试分配 X 字节)

我最近在尝试克隆 git 存储库时收到以下错误日志:

remote: Counting objects: 4607, done.
error: git upload-pack: git-pack-objects died with error.B/s      
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
remote: fatal: Out of memory, malloc failed (tried to allocate 119483755 bytes)
remote: aborting due to possible repository corruption on the remote side.
fatal: early EOF
fatal: index-pack failed
Run Code Online (Sandbox Code Playgroud)

经过调查,看起来错误来自 repo 服务器。我通过 ssh 连接并尝试了以下所有方法(基本上是谷歌结果的前 2 页提出的所有解决方案):

  • 通过添加以下行来修改配置文件:

    [core]
        packedGitLimit = 512m
        packedGitWindowSize = 512m
    [pack]
        windowMemory = 512m
        packSizeLimit = 512m
        deltaCacheSize …
    Run Code Online (Sandbox Code Playgroud)

git out-of-memory

6
推荐指数
1
解决办法
1万
查看次数

在真实设备上使用openCV框架编译iOS应用程序时出错

使用最新的开放式cv框架,我无法在IOS设备上编译代码.我正面临以下错误.

架构arm64的未定义符号:"_ png_init_filter_functions_neon",引自:opencv2中的_png_read_filter_row(pngrutil.o)ld:未找到架构arm64 clang的符号:错误:链接器命令失败,退出代码为1(使用-v查看调用)

相同的应用程序能够为模拟器编译,但不能为ios设备编译.谁能告诉我为什么我会遇到这个问题.提前致谢.

opencv compiler-errors ios

5
推荐指数
1
解决办法
4272
查看次数

如何支持使用UILabel自动调整UITableViewCell的大小

我试图弄清楚如何获得包含uitextview的tableview单元格的正确高度,以便显示uitextview中的所有内容.textview不可编辑且不可滚动,这意味着uitextview的字符串是已知的.我尝试简单地返回故事板中的tableview单元格的高度,heightForRowAtIndexPath但是如果内容太大则会切断内容.我也尝试计算textView的高度,heightForRowAtIndexPath但它在运行时抛出一个错误:

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        let cellInfo = UserCellsArray[indexPath.section]
        switch cellInfo {
        case .userInfo: return 104
        case .ubio:
            let cell = tableView.dequeueReusableCellWithIdentifier(cellInfo.description, forIndexPath: indexPath) as! UserProfileTableViewCell //error
            let oldHeight = cell.userBio.frame.size.height
            cell.userBio.text = self.bio
            var bodyframe = cell.userBio.frame
            bodyframe.size = cell.userBio.contentSize
            let newHeight = cell.userBio.contentSize.height
            return tableView.rowHeight - oldHeight + newHeight
        }
    } 
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift swift2

1
推荐指数
1
解决办法
1753
查看次数

是否有更好的方法将自定义类保存到NSUserDefaults而不是使用NSCoder编码和解码所有内容?

我当前的类有大约50行只是编码和解码变量,以便我的类与NSUserDefaults兼容.有没有更好的方法来处理这个?

例:

 init(coder aDecoder: NSCoder!) {
    lightEnabled = aDecoder.decodeBoolForKey("lightEnabled")
    soundEnabled = aDecoder.decodeBoolForKey("soundEnabled")
    vibrateEnabled = aDecoder.decodeBoolForKey("vibrateEnabled")
    pulseEnabled = aDecoder.decodeBoolForKey("pulseEnabled")
    songs = aDecoder.decodeObjectForKey("songs") as! [Song]
    currentSong = aDecoder.decodeIntegerForKey("currentSong")
    enableBackgroundSound = aDecoder.decodeBoolForKey("enableBackgroundSound")
    mixSound = aDecoder.decodeBoolForKey("mixSound")
    playSoundInBackground = aDecoder.decodeBoolForKey("playSoundInBackground")
    duckSounds = aDecoder.decodeBoolForKey("duckSounds")
    BPMBackground = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("BPMBackgorund") as! NSData) as! UIColor!
    BPMPulseColor = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("BPMPulseColor") as! NSData) as! UIColor!
    TempoBackGround = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("TempoBackGround") as! NSData) as! UIColor!
    TempoPulseColor = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("TempoPulseColor") as! NSData) as! UIColor!
    TimeBackGround = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("TimeBackGround") as! NSData) as! UIColor!
    TimeStrokeColor = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("TimeStrokeColor") as! NSData) as! UIColor! …
Run Code Online (Sandbox Code Playgroud)

archiving nsuserdefaults ios swift

1
推荐指数
1
解决办法
882
查看次数