小编Abr*_*m P的帖子

无法将“UITableViewCell”(0x10c111c68)类型的值转换为子类

我正在尝试构建一个相当直接的数据表,并遵循本教程:http : //www.raywenderlich.com/87975/dynamic-table-view-cell-height-ios-8-swift

我有以下自定义单元格类:

import Foundation
import UIKit

class WorkItemCell: UITableViewCell {
  @IBOutlet var titleLabel: UILabel!
}
Run Code Online (Sandbox Code Playgroud)

以及我的 TableClass 中的以下函数:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = self.tableView.dequeueReusableCellWithIdentifier("WorkItemCell") as! WorkItemCell
    cell.textLabel?.text = self.work[indexPath.row]["name"] as! String
    return cell
}
Run Code Online (Sandbox Code Playgroud)

这导致:

Could not cast value of type 'UITableViewCell' (0x10c111c68) to 'proj.WorkItemCell' (0x10a84c4c0).

为什么?我该如何解决?

uitableview ios swift

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

Xcode 未检测到 Pods 目录

我正在与一位同事一起开发 Swift 应用程序,我们通过 github 管理我们的版本。他添加了一些 CocoaPods。

我跑了

gem install cocoapods pod install

proj/Pods 目录中填充了 Pods,但是在第一次时import,Xcode 无法使用 进行构建,并且 Xcode在 Pods 目录中看不到No such module Alamofire任何其他内容。Pods.debug.xcconfigPods.release.xcconfig

我该如何解决这个问题?

xcode dependency-management ios cocoapods swift

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

Haskell Safe IO

我正在尝试编写一个简单的函数来安全地读取文件(如果存在),如果文件不存在则不执行任何操作:

safeRead :: String -> IO ()
safeRead path = readFile path `catch` handleExists
  where handleExists e
          | isDoesNotExistError e = return ()
          | otherwise = throwIO e
Run Code Online (Sandbox Code Playgroud)

这在编译时失败了

Couldn't match type ‘[Char]’ with ‘()’
Expected type: IO ()
  Actual type: IO String
In the first argument of ‘catch’, namely ‘readFile path’
In the expression: readFile path `catch` handleExists
Run Code Online (Sandbox Code Playgroud)

这是有道理:t readFile的readFile :: FilePath -> IO String.例如返回IO String(并且IO String不相同IO ())的函数

将签名更改为 …

io haskell types io-monad

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

PostgreSQL无法在Windows XP上启动

我正在尝试针对PostgreSQL数据库设置运行Ruby on Rails的Windows XP测试代理.我已经安装了PostgreSQL 9.2 for Windows,默认设置.但是,当我尝试从服务控制面板启动服务时,会出现以下错误消息(与我尝试将其设置为的用户无关):

   The postgres-9.2 -PostgreSQL Server 9.2 service on Local Computer started and then stopped. Some services 
   stop automatically if they have work to do, for example, the Performance Logs and Alerts service.
Run Code Online (Sandbox Code Playgroud)

如果我尝试从命令行启动它(cmd.exe或git bash无关紧要):

   E:\PostgreSQL\9.2\bin\pg_ctl.exe start  -D E:\PostgreSQL\9.2\data
Run Code Online (Sandbox Code Playgroud)

它会声称:

   server starting
Run Code Online (Sandbox Code Playgroud)

但是它将无法启动(rake db:migrate将报告服务器未运行,任务管理器中缺少postgresql进程,服务在服务列表中列为向下,并且

  E:\PostgreSQL\9.2\bin\pg_ctl.exe stop  -D E:\PostgreSQL\9.2\data
Run Code Online (Sandbox Code Playgroud)

会报告

  pg_ctl: PID file "E:/PostgreSQL/9.2/data/postmaster.pid" does not exist Is server running?
Run Code Online (Sandbox Code Playgroud)

尝试通过pg_ctl将其作为服务器启动时:

  E:\PostgreSQL\9.2\bin\pg_ctl.exe runservice  -D E:\PostgreSQL\9.2\data
Run Code Online (Sandbox Code Playgroud)

失败:

  pg_ctl: could not start service PostgreSQL: error code 1063
Run Code Online (Sandbox Code Playgroud)

编辑: …

postgresql service windows-xp

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

ChicagoBoss拒绝用户作为模型名称

所以按照本教程:

https://github.com/evanmiller/ChicagoBoss/wiki/An-Evening-With-Chicago-Boss

除了我不能使用"user"作为模型名称之外,一切都像魅力一样.最小用例:

 -module(customer, [Id, Name, PasswordHash]).
 -compile(export_all).
Run Code Online (Sandbox Code Playgroud)

这样可以正常工作.

 -module(user, [Id, Name, PasswordHash]).
 -compile(export_all).
Run Code Online (Sandbox Code Playgroud)

这将堆栈跟踪,然后./rebar compile,它抛出:

 ERROR: pre_compile failed while processing /Users/abe/github/awesome-name: {'EXIT',{{badmatch,{error,["code reload failed: user"]}},
     [{boss_load,load_all_modules,3,
                 [{file,"src/boss/boss_load.erl"},{line,30}]},
      {boss_load,load_all_modules_and_emit_app_file,2,
                 [{file,"src/boss/boss_load.erl"},{line,44}]},
      {boss_rebar,compile,4,
                  [{file,"/Users/abe/github/ChicagoBoss/priv/rebar/boss_rebar.erl"},
                   {line,85}]},
      {boss_plugin,pre_compile,2,
                   [{file,"priv/rebar/boss_plugin.erl"},{line,105}]},
      {rebar_core,run_modules,4,[]},
      {rebar_core,execute,5,[]},
      {rebar_core,process_dir1,6,[]},
      {rebar_core,process_commands,2,[]}]}}
Run Code Online (Sandbox Code Playgroud)

这发生在{db_adapter, mock}和{db_adapter, mongo}.

谁知道发生了什么事?是否在某处保留了用户关键字?如果它是......我在文档中找不到它

erlang chicagoboss

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

复合ng-if表达式未执行

假设我有以下代码:

<div ng-if="Array.isArray(list)" ng-repeat="item in list">{{item}}</div>
<div ng-if="!Array.isArray(list)"> Not a list </div>
Run Code Online (Sandbox Code Playgroud)

表达式总是评估不是列表.为什么?

Plunker:http://plnkr.co/edit/jlH0z3tLN6qbRowD5NGQ?p=preview

javascript angularjs

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

类型枚举的数组从Postgres作为字符串返回

给定一个自定义枚举: CREATE TYPE vehicle AS ENUM ('car', 'truck', 'bicycle');

像这样的表:

CREATE TABLE vehicle_events (
  timestamp timestamptz NOT NULL DEFAULT current_timestamp,
  labels vehicle[] NOT NULL,
  mentions int4[] NOT NULL DEFAULT '{}'
);
Run Code Online (Sandbox Code Playgroud)

当这样从我们的节点应用程序中查询时:

SELECT * FROM vehicle_events;

这将返回一个json结构,如下所示:

[{"timestamp": "January, 06 2016 23:04:56", "labels": "{'car'}", "mentions": [1,2,3,4]}]

我的问题确实是,为什么labels数组以字符串形式返回(还请注意,提到的base类型的数组不是)?这是因为它是一个数组ENUM吗?如果是这样,如何将其强制放入常规数组中?为什么postgres以这种方式退回它?

sqlfiddle链接:http ://sqlfiddle.com/#!15/637ce/1

postgresql node.js node-postgres

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