小编spa*_*guy的帖子

将文件路径从NSString转换为NSURL

我正在顺利地完成Cocoa,但这个问题看起来很基本,它取消了我学到的所有很酷的东西.:/

我有一个生成的文件路径,它需要是NSURL格式.从研究来看,这是我写的代码:

NSLog(@"Old path = %@", pathToFile);
NSURL *xmlURL = [[[NSURL alloc] init] fileURLWithPath:pathToFile];
NSLog(@"New path = %@", [xmlURL absoluteString]);
Run Code Online (Sandbox Code Playgroud)

并输出:

2010-01-27 15:39:22.105 MusicLibraryStats[28574:a0f] Old path = file://localhost/Users/[username]/Music/iTunes/iTunes%20Music%20Library.xml
2010-01-27 15:39:22.105 MusicLibraryStats[28574:a0f] New path = (null)
Run Code Online (Sandbox Code Playgroud)

首先,alloc-init甚至不需要; 其他人似乎逃脱了它.在这种情况下,如果我没有alloc-init,我会在该行上收到"无法识别的选择器"错误.当然,现在我只是变老了(null).

我在哪里?

谢谢!

cocoa objective-c

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

Karma抱怨'模块不可用'

直到几天前我的单元测试运行良好,我的代码在浏览器中完美运行.然后我添加了一个名为'profile'的存根模块后注意到了这一点:

INFO [karma]: Karma v0.12.24 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Mac OS X)]: Connected on socket 7W-0vnkWZaWxYYtwFrhT with id 9336780
PhantomJS 1.9.7 (Mac OS X) ERROR
  Error: [$injector:nomod] Module 'profile' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
Run Code Online (Sandbox Code Playgroud)

现在,我意识到这是世界上最常见的AngularJS错误,我已经很好地调试了这个,但是对于我的生活,我无法让它消失.细节:

  • 代码在浏览器中工作,没有错误.
  • Karma以这种方式获取我的文件:

        'node_modules/angular/angular.js',
        'node_modules/angular-mocks/angular-mocks.js',
        'node_modules/angular-ui-router/release/angular-ui-router.js',
        'node_modules/angular-bootstrap/ui-bootstrap.js',
        'node_modules/angular-ui-form-validation/dist/angular-ui-form-validation.js',
        'node_modules/angular-animate/angular-animate.js',
        'client/app/**/*.js'
    
    Run Code Online (Sandbox Code Playgroud)
  • 主模块依赖于已经声明的'profile'.

  • profile.js,profile.controller.js和profile.controller.spec.js是由cg-angular-fullstack生成的存根,没有特殊代码.默认情况下,生成器将它们全部放在主模块中,因此我将每个模块更改为"配置文件".

我完全没有想法.如果我无法调试这个,我将不得不假设我的整个应用程序设计存在缺陷并重新启动.:(

javascript angularjs karma-runner

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

Sencha Touch 2中的Ext.define/Ext.extend

我刚开始拿起Sencha Touch 2 MVC.我有丰富的Ext 3经验,但这是一个全新的世界.

我似乎无法在构建视图方面走得很远.我根据我在互联网上看到的内容将我的代码分为两个方向,但都不起作用.

路径1

我的app.js:

Ext.application({
        name: 'BkAdmin',
        views: ['LoginForm'],
        launch: function() {
            Ext.create('BkAdmin.view.LoginForm');
    }
});
Run Code Online (Sandbox Code Playgroud)

我的观点/ LoginForm.js:

Ext.define('BkAdmin.view.LoginForm', {
        extend: 'Ext.form.FormPanel',
        config: {
            fullscreen: true,
            initComponent: function() {
                        alert('yo!');
                        BkAdmin.view.LoginForm.superclass.initComponent.apply(this, arguments);
            }
        }
    }
);
Run Code Online (Sandbox Code Playgroud)

这加载没有错误,我甚至可以在配置部分添加表单项.但是,initComponent()莫名其妙地永远不会被调用,因此视图完全不灵活.

路径2

我的app.js:

Ext.application({
    name: 'BkAdmin',
    views: ['LoginForm'],
    launch: function() {
    BkAdmin.view.LoginForm = new BkAdmin.view.LoginForm();
    }
});
Run Code Online (Sandbox Code Playgroud)

我的观点/ LoginForm.js:

BkAdmin.view.LoginForm = Ext.extend(Ext.form.FormPanel, {
    fullscreen: true,
    initComponent: function() {
                alert('yo!');
        BkAdmin.view.LoginForm.superclass.initComponent.apply(this, arguments);
    }
});
Run Code Online (Sandbox Code Playgroud)

这种平坦无效.Chrome报告'无法设置属性'LoginForm'未定义'...如何查看未定义的视图?此外,它还说'即使文件已加载,也不会声明以下类:'BkAdmin.view.LoginForm'.' 当然看起来向我宣布.

这里有很多问题:在上述路径中我做错了什么?如何在路径1中调用initComponent()并使路径2工作?引用哪个代码 - unquote更好用?

谢谢!

javascript model-view-controller sencha-touch sencha-touch-2

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

无法从JavaScript调用JNLP部署的applet代码

这是我关于Java的第一个问题,所以请耐心等待.

我从这段代码构建了一个名为HelloWorldApp.class的愚蠢的简单applet类:

import java.applet.Applet;

class HelloWorldApp extends Applet
{
    static final long serialVersionUID = 6636669702238171717L;
    public String test()
    {
        return "Hello World!"; // Display the string.
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我从所述类文件中构建了一个jar文件.之后,我做了一个愚蠢的简单JNLP文件:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="/Content/applets" href="/Content/applets/datadelivery.jnlp">
    <information>
        <title>Hello World</title>
        <vendor>Me</vendor>
    </information>
    <resources>
        <!-- Application Resources -->
        <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
        <jar href="HelloWorldApp.jar" main="true" />

    </resources>
    <applet-desc 
         name="Test Applet"
         main-class="HelloWorldApp"
         width="300"
         height="50">
     </applet-desc>
     <update check="background"/>
</jnlp>
Run Code Online (Sandbox Code Playgroud)

我扔了目录/ Content/applets中的所有三个项目.最后,为了将它们组合在一起,我将其放在HTML文档的正文中:

<script type="text/javascript">
    var attributes = {
        id:'deliveryApplet',
        code: 'HelloWorldApp',
        // note: I tried including …
Run Code Online (Sandbox Code Playgroud)

javascript java jnlp applet

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

HTML5 视频在 IE 中播放失败(或:缺少范围请求)

我为之前在 SO 上问过一万次的问题而道歉。这种情况似乎与其他情况不同。简而言之,通过 Firefox 和 Chrome 播放视频总是有效,但在 Internet Explorer、所有版本、所有 Windows 版本中总是失败。

我有一个根据 Microsoft 的 HTML5 建议设置的网页。模态窗口提供视频:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    </head>
    <body>
        <div class="popupwindow">
            <video controls autoplay preload="auto" style="width:100%">
                <source src="streamvideo.rails?file=$fileName" type="video/mp4" />
            </video>
        </div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

streamvideo.rails 是 Castle Monorail C# 函数,它获取云服务器中的视频文件作为 Stream 并将其作为范围请求流式传输回来。

首先,我确定这不是常见的问题:编解码器可能没问题,响应的 Content-Type 是正确的(视频/mp4)并且 IE 甚至正确地接收视频,至少最初是这样。浏览器内的网络嗅探器显示它收到了一小块 MP4 文件,然后停止了。

我注意到一个奇怪的地方:IE 没有将视频请求作为范围请求,而 Chrome/FF 是。Chrome 的标题:

GET [my URL]?fileName=e65b0b0d-0911-4e3f-bc71-7b5d5a65db57.mp4 HTTP/1.1
Host: localhost
Connection: keep-alive
Accept-Encoding: identity;q=1, *;q=0
User-Agent: Mozilla/5.0 …
Run Code Online (Sandbox Code Playgroud)

html video internet-explorer http-headers

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

整合Travis/Sauce Labs时,"无法找到Angular"

我正在努力让Travis CI使用Sauce Labs进行Protractor测试.隧道工作正常,我的Express服务器明显启动并保持运行状态http://localhost:9000,但我的Protractor测试很快失败并出现错误Error: Angular could not be found on the page http://localhost:9000/ : retries looking for angular exceeded.互联网上的所有建议通常都涉及不使用Angular 1.0(使用1.3),延长超时(这样做),或强制Protractor查看<html>ng-app指令(这样做).我没有想法.

相关配置:

protractor.conf.js

exports.config = {
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,
baseUrl: 'http://localhost:9000',

specs: ['e2e/**/*.spec.js'],
framework: 'jasmine',
maxSessions: 1,
allScriptsTimeout: 30000,
rootElement: 'html',
multiCapabilities: [
    {'browserName': 'chrome'},
    {'browserName': 'firefox'},
    {'name': 'diplomacy'},
    {'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER ? process.env.TRAVIS_JOB_NUMBER : null},
    {'build': process.env.TRAVIS_BUILD_NUMBER ? process.env.TRAVIS_BUILD_NUMBER : null}
],
jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 360000,
    includeStackTrace: true
}
}
Run Code Online (Sandbox Code Playgroud)

main.spec.js

'use strict'; …
Run Code Online (Sandbox Code Playgroud)

travis-ci angularjs saucelabs protractor

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

从beginSheetModalForWindow获取URL:

我正在使用OpenPanel来获取文件路径URL.这有效:

[oPanel beginSheetModalForWindow:theWindow completionHandler:^(NSInteger returnCode)
{
 NSURL *pathToFile = nil;

 if (returnCode == NSOKButton)
     pathToFile = [[oPanel URLs] objectAtIndex:0];
}];
Run Code Online (Sandbox Code Playgroud)

这不会导致"只读变量的赋值"错误:

NSURL *pathToFile = nil;
[oPanel beginSheetModalForWindow:theWindow completionHandler:^(NSInteger returnCode)
{
 if (returnCode == NSOKButton)
     pathToFile = [[oPanel URLs] objectAtIndex:0];
}];
return pathToFile;
Run Code Online (Sandbox Code Playgroud)

通常,任何从oPanel上下文中提取pathToFile的尝试都失败了.对于小情况来说,这不是什么大问题,但随着我的代码的增长,我不得不在不适当的区域内填充所有内容 - XML解析,核心数据等.我该怎么做才能提取pathToFile?

谢谢.

cocoa asynchronous nsopenpanel objective-c-blocks

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

使用Vuetify / Flexbox滚动div布局

一旦我使用Angular Material(以及因此使用flexbox)设置了UI,如下所示:

Flexbox布局

这两个div在父容器中。我真正喜欢的布局是,容器的高度由第一个div决定(隐式地通过最大宽度和缩放),第二个div尊重该高度并为任何溢出创建滚动。

我正在用VueJS和Vuetify重写应用程序,但是我无法翻译旧版式。我尝试对原始CSS进行逆向工程,但是Angular Material创建的结构使这一工作变得困难。

这是我最近来的,但是滚动区域仍然在容器外部溢出:

    <v-container fluid>
        <v-layout v-bind="layout">
            <v-flex md8 sm12 id="mapContainer">
                <map-phase-viewer :game="game" :phases="phases"></map-phase-viewer>
            </v-flex>
            <v-flex fluid id="gameToolsContainer" class="elevation-1">
                <div style="overflow-y: scroll;">
                    <v-list subheader v-if="game.Started" dense>
                        <div v-for="power in variant.Nations" :key="power + 'UnitSection'">
                    <v-subheader class="nationSubheader">{{power}}</v-subheader>
                    <province-list-item
                        v-for="unit in getCurrentPhase().Units"
                        v-if="unit.Unit.Nation === power"
                        :key="unit.Province"
                        :unit="unit">
                    </province-list-item>
                </div>
                    </v-list>
                </div>
            </v-flex>
        </v-layout>
    </v-container>
Run Code Online (Sandbox Code Playgroud)

使用Vuetify甚至原始CSS,实现此布局所需的最低结构是什么?为简单起见,请忽略您在原始文档中看到的选项卡。

css flexbox vuetify.js

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

在 Sequelize 中查询关联表

我有两个表 (usersgames) 由关联表 ( game_players) 连接,创建了多对多关系:

models.Game.belongsToMany(models.User, { through: models.GamePlayer, as: 'players' });
models.User.belongsToMany(models.Game, { through: models.GamePlayer, foreignKey: 'user_id' });
Run Code Online (Sandbox Code Playgroud)

除了外键user_idand 之外game_idgame_players还有一些额外的列用于链接特定的数据:

sequelize.define('game_player', {
    isReady: {
        defaultValue: false,
        type: Sequelize.BOOLEAN,
        field: 'is_ready'
    },
    isDisabled: {
        defaultValue: false,
        type: Sequelize.BOOLEAN,
        field: 'is_disabled'
    },
    powerPreferences: {
        type: Sequelize.TEXT,
        field: 'power_preferences'
    },
    power: {
        type: Sequelize.STRING(2),
        defaultValue: '?'
    }
}, {
    underscored: true
});
Run Code Online (Sandbox Code Playgroud)

假设我想获取一个游戏并急切地加载活跃玩家。这是我的第一次尝试:

db.models.Game.findAll({
    include: [{
        model: db.models.User, …
Run Code Online (Sandbox Code Playgroud)

javascript sql sequelize.js

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

无法连接到自托管WCF服务

我正在尝试构建一个相当基本的WCF SOAP Web服务,作为Windows服务自托管.Windows服务本身在我的机器上启动并运行 - 我无法通过Visual Studio或Web浏览器在本地访问它.

相关的C#代码如下.假设MyDummyService实施合同IDummyService:

public class Program : ServiceBase
{
    private ServiceHost host = null;
    private readonly Uri baseAddress = new Uri("http://localhost:8000/DummyAPI");

    public static readonly ILog log = LogManager.GetLogger(typeof(Program));
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    public static void Main(string[] args)
    {
        ServiceBase.Run(new Program());
    }

    public Program()
    {
        this.ServiceName = "DummyService";
    }

    protected override void OnStart(string[] args)
    {
        log.Info("Starting service");

        try
        {
            base.OnStart(args);

            host = new ServiceHost(typeof(MyDummyService), baseAddress); …
Run Code Online (Sandbox Code Playgroud)

c# wcf soap windows-services

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