我需要将一个变量从AppDelegate传递给另一个我创建的类来保存项目的全局变量,我无法找到使其工作的方法.
这是AppDelegate中的代码:
func application(application: UIApplication!, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData!) {
println("Device's token is: \(deviceToken)")
//Global Variables Class Instance
let globals:Globals = Globals()
globals.setDeviceToken("test1") //method1 not working
globals.deviceToken = "test2" //method2 not working
}
Run Code Online (Sandbox Code Playgroud)
这是我的Globals类:
public class Globals {
var deviceToken = String()
init() {
//nothing
}
func setDeviceToken(s:String){
deviceToken = s
}
func getDeviceToken() -> String {
return deviceToken
}
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试从项目的其他文件打印值,我将无法获得任何内容,只是一个空字符串.
class ViewController: UIViewController {
//Global Variables Class Instance
let globals:Globals = Globals()
override func viewDidLoad() {
println(globals.getDeviceToken()) //return empty …Run Code Online (Sandbox Code Playgroud) 我试图通过不同的参数获得不同的响应,但有些东西不起作用.
这是我的API:
## Question [/questions/{question_id}]
A Question object has the following attributes:
+ Parameters
+ question_id: `1` (number, required) - ID of the Question in form of an integer
### View a Questions Detail [GET]
+ Request
+ Header
X-Custom-Header : 1
+ Response 200 (application/json)
{
"id": "1",
"name": "Marco"
}
+ Request
+ Header
X-Custom-Header : 2
+ Response 200 (application/json)
{
"id: "2",
"name": "Lucas"
}
Run Code Online (Sandbox Code Playgroud)
但是在调用/ questions/1或/ questions/2时,响应始终是相同的:
{
"id": "1",
"name": "Marco"
}
Run Code Online (Sandbox Code Playgroud)
怎么了?
谢谢
我已经创建了两个div,我希望它们彼此相邻,但即使它们有显示,一个也总是向下:内联块.怎么了?我不明白.
.container {
width: 200px;
border: 1px solid black;
}
.a {
display: inline-block;
background: red;
}
.b {
width: 20px;
display: inline-block;
background: blue;
}Run Code Online (Sandbox Code Playgroud)
<div class="container">
<div class="a">hello hello hello hello hello hello hello</div>
<div class="b">aaa</div>
</div>Run Code Online (Sandbox Code Playgroud)
我注意到使用不同的应用程序,即使你从xcode中删除iPad的兼容性(见下图)

该应用程序仍然会在iTunes应用程序页面中显示与iPad兼容(参见下图):

因此,我想知道,Whatsapp是如何从它的应用程序中删除iPad兼容性的?(见下图):

谢谢
我正在使用apiary创建一些API ,因此使用的语言是JSON.
我们假设我需要代表这个资源:
{
"id" : 9,
"name" : "test",
"customer_id" : 12,
"user_id" : 1,
"store_id" : 3,
"notes" : "Lorem ipsum example long text"
}
Run Code Online (Sandbox Code Playgroud)
难道是正确的根据ID引用其他资源(12,1,3),或者我应该指定这些资源的URL(即/customers/12,/users/1,/stores/3)?
我没有使用HATEOAS,我有点困惑.
由于某种原因Sublime,没有加载PHP文件的语法颜色,但似乎与其他文件(即HTML)工作正常.
我该如何解决这个问题?我已经尝试重新启动应用程序,但没有任何变化.
编辑:

谢谢
将cordova更新到版本4.3.0后,命令:
cordova build
Run Code Online (Sandbox Code Playgroud)
返回以下错误:
module.js:340
throw err;
^
Error: Cannot find module 'Q'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/lib/check_reqs.js:25:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
ERROR building one of the platforms: Error: /Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone …Run Code Online (Sandbox Code Playgroud) 我创建了一个控制台命令,我需要截断一个表.
阅读类参考:http://www.yiiframework.com/doc-2.0/yii-db-command.html#truncateTable()-detail我不能够了解哪些文件,我需要为了执行此命令,包括.
我包括:
use yii\db\Command;
use yii\db\Connection;
Run Code Online (Sandbox Code Playgroud)
但不确定哪一个是正确的.
我试图执行:
$command = Yii::$app->db->truncateTable('user');
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误:
消息'调用未知方法:yii\db\Connection :: truncateTable()'的异常'yii\base\UnknownMethodException'
和:
Yii::$connection->createCommand()->truncateTable('user');
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误:
PHP致命错误'yii\base\ErrorException',带有消息'访问未声明的静态属性:Yii :: $ connection'
我真的不明白我需要做什么.
在Div上使用背景图像时,我无法显示图像的完整高度,无法使用height:auto;或height: 100%.为什么这样?我该如何解决这个问题?
我在这里创建了一个JS小提琴:https://jsfiddle.net/2d0npz2v/5/
body, html {
height: 100%;
margin: 0px;
}
.imageContainer2 {
background-image: url("http://i.imgur.com/AWi7r5m.jpg");
background-position: center top;
background-size: 100% auto;
height: 100%;
}Run Code Online (Sandbox Code Playgroud)
<div class="imageContainer2"></div>Run Code Online (Sandbox Code Playgroud)
更新 为了清晰起见,图像需要100%宽度和自动高度(不在底部切割).此示例有效,但它使用"content"属性而不是"background-image": https: //jsfiddle.net/j47a6x7s/.我正在寻找相同的行为,但没有使用内容.
css ×2
html ×2
ios ×2
php ×2
rest ×2
api ×1
api-design ×1
apiary ×1
apiary.io ×1
apiblueprint ×1
app-store ×1
appdelegate ×1
assemble ×1
cordova ×1
cordova-cli ×1
css3 ×1
hateoas ×1
ipad ×1
json ×1
node-modules ×1
npm ×1
overflow ×1
sublimetext2 ×1
swift ×1
xcode ×1
yii2 ×1