小编JuJ*_*oDi的帖子

如何用iphone计算我们汽车的速度

对于我的应用程序,我想用iphone计算我的汽车/自行车速度.我怎样才能做到这一点?理想情况下,它应该在后台持续运行.

iphone performance objective-c cllocation ios

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

Markdown内部链接在BitBucket README.md中不起作用

我在BitBucket项目中有一个README.md文件

## Table of Contents

* [Document Organization](#document-organization)

...

## Document Organization
Run Code Online (Sandbox Code Playgroud)

当我使用Sublime Text在浏览器中打开markdown预览时,目录中的链接会跳转到相应的部分,但是当我将文件上传到BitBucket时,URL似乎是正确的,但它不会跳转到该部分.

BitBucket存储库是私有的,所以我无法共享它.

我怎样才能解决这个问题?

markdown bitbucket

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

如何使用ExpressJS检查Content-Type?

到目前为止,我有一个非常基本的RESTful API,我的Express应用程序配置如下:

app.configure(function () {
  app.use(express.static(__dirname + '/public'));
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
});

app.post('/api/vehicles', vehicles.addVehicle);
Run Code Online (Sandbox Code Playgroud)

如何/在哪里可以添加阻止请求到达我的中间件app.post以及app.get内容类型不是application/json

中间件只应将具有不正确内容类型的请求停止到以/api/.开头的URL .

node.js express

11
推荐指数
2
解决办法
2万
查看次数

跨多个模型导出和重用我的mongoose连接

我有一个目录结构

./lib
./lib/model1.js
./lib/model2.js
Run Code Online (Sandbox Code Playgroud)

两个模型都使用mongoose连接到同一个MongoDB实例,但定义了不同的模型:

// model1.js
var mongoose = require ('mongoose');
mongoose.connect ('bla')
var db = mongoose.connection;

var schema1, model1;

db.on('error', console.error.bind(console, 'database, why you no connect?'));

db.once('open', function callback () {

  schema1 = mongoose.Schema({
    // some properties
  });

  model1 = mongoose.model1 ('model1', schema1);

});
Run Code Online (Sandbox Code Playgroud)

创建数据库连接一次并为每个模型重用它的最佳方法是什么?什么是最好的目录结构?也许./lib/middleware/db.js

这个问题似乎很相关,但它使用mongodb npm模块而不是mongoose,问题不清楚,所有作者的评论都被删除了.

mongoose mongodb node.js

9
推荐指数
2
解决办法
8391
查看次数

正确访问segue的目标视图控制器以分配协议代理

我在实现选择列表时遇到了集成segue和协议的一些问题.

在我的选择列表中.h我有:

#import <UIKit/UIKit.h>

@protocol SelectionListViewControllerDelegate <NSObject>
@required
- (void)rowChosen:(NSInteger)row;
@end

@interface SelectColor : UITableViewController <NSFetchedResultsControllerDelegate>
-(IBAction)saveSelectedColor;
@property (nonatomic, strong) id <SelectionListViewControllerDelegate> delegate;
@end
Run Code Online (Sandbox Code Playgroud)

在我的选择列表中.我有:

@implementation SelectColori
@synthesize delegate;

//this method is called from a button on ui
-(IBAction)saveSelectedColore
{
    [self.delegate rowChosen:[lastIndexPath row]];
    [self.navigationController popViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)

我想通过从另一个表视图执行segue来访问此选择列表视图:

@implementation TableList
...
- (void)selectNewColor
{
    SelectColor *selectController = [[SelectColor alloc] init];
    selectController.delegate = (id)self;
    [self.navigationController pushViewController:selectController animated:YES];

    //execute segue programmatically
    //[self performSegueWithIdentifier: @"SelectColorSegue" sender: self];
}

- (void)rowChosen:(NSInteger)row
{
    UIAlertView * errorAlert …
Run Code Online (Sandbox Code Playgroud)

delegates controller protocols ios segue

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

如何将需要静态IP的应用程序部署到Heroku?

我有一个在Heroku上托管的rails应用程序,我需要与第三方支付提供商集成.支付提供商要求我的应用程序将具有用于传入和传出HTTPS请求的静态IP.我想在Linode VPS上部署代理,以便它可以作为代理中继信息.将请求转发给服务提供商似乎很容易,我只是使用他们的IP.

我可以将来自服务提供商的请求转发到heroku应用程序吗?我可以使用URL(https://myapp.herokuapp.com)中继请求吗?

建议使用的代理服务器是什么?

heroku static-ip-address

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

对于mongoose Document#update,所有可能的回调参数是什么?

这看起来很难记录.文档示例刚刚callback传递给更新.有一个重定向到Model.update 这里的链接,示例显示了回调的参数(err, numberAffected, raw).

Document#update回调是否传递相同的参数?我希望得到更新的文件.我最初的搜索是基于如何在mongo db中更新文档,但即使答案也没有解释甚至列出回调的参数.

mongoose mongodb node.js

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

声明符合Swift协议的变量或常量

在Swift中,如何声明符合协议的变量(或常量)?

我试过了

let whatever: protocol <myProtocol>
Run Code Online (Sandbox Code Playgroud)

let whatever: myProtocol
Run Code Online (Sandbox Code Playgroud)

但是在设置它时我得到了错误

Cannot convert the expression's type '()' to type 'myProtocol'
Run Code Online (Sandbox Code Playgroud)

protocols swift

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

NSKeyedArchiver unarchiveObjectWithFile与EXC_BAD_INSTRUCTION崩溃

我有以下代码,用于获取已归档的对象的路径

let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
let path = paths[0] as String
let archivePath = path.stringByAppendingString("archivePath")
Run Code Online (Sandbox Code Playgroud)

当我运行此代码时,它会在NSSearchPathForDirectoriesInDomainslldb显示的调用时崩溃

Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
Run Code Online (Sandbox Code Playgroud)

在Xcode的变量视图中,我看到路径字符串设置为我所期望的.在Swift中获取用户目录以归档/取消归档对象的正确方法是什么?

更新:

看来这实际上是因为我对NSKeyedUnarchiver的使用而崩溃了:

stopwatches = NSKeyedUnarchiver.unarchiveObjectWithFile(archivePath) as Stopwatch []
Run Code Online (Sandbox Code Playgroud)

Stopwatch是一个实现NSCoding的类,stopwatches是执行unarchiving的视图所拥有的数据源(一组Stopwatches).

更新2:

存档的对象图是Stopwatches数组.NSCoding实现如下:

func encodeWithCoder(aCoder: NSCoder!) {
    aCoder.encodeBool(self.started, forKey: "started")
    aCoder.encodeBool(self.paused, forKey: "paused")
    aCoder.encodeObject(self.startTime, forKey: "startTime")
    aCoder.encodeObject(self.pauseTime, forKey: "pauseTime")
    aCoder.encodeInteger(self.id, forKey: "id")
}

init(coder aDecoder: NSCoder!) {
    self.started = aDecoder.decodeBoolForKey("started")
    self.paused = aDecoder.decodeBoolForKey("paused")
    self.startTime = aDecoder.decodeObjectForKey("startTime") as NSDate
    self.pauseTime = aDecoder.decodeObjectForKey("pauseTime") as NSDate
    self.id …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch nscoding nskeyedunarchiver swift

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

使用Google地图和Apple Maps URL计划自动开始导航

在iOS上使用URL方案启动Google地图Apple地图时,有没有办法自动启动导航?

我看到两个可选参数,但没有用户输入就没有开始导航.

google-maps url-scheme ios apple-maps

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