小编Max*_*eod的帖子

将变量初始化为nil是一种好习惯吗?

将变量初始化为nil?是一种好习惯吗?

我问的是因为当我在我的项目上运行分析器时,我收到了警告.

 NSString *q;

    if(sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil) == SQLITE_OK)
    {
        sqlite3_step(statement);
        selectedQuestion =[NSString stringWithFormat: @"%s",(char *)sqlite3_column_text(statement, 0)];
        sqlite3_finalize(statement);
    }

    sqlite3_close(database);

    return q; //Undefined or garbage value returned to caller
Run Code Online (Sandbox Code Playgroud)

当我更改代码时,警告消失了:

NSString *q = nil;
Run Code Online (Sandbox Code Playgroud)

null objective-c clang-static-analyzer ios

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

请在Apple SpriteKit示例代码中解释uint32_t和0x1 << 0

我在SpriteKit的苹果示例代码中找到了几行

static const uint32_t missileCategory  =  0x1 << 0;
Run Code Online (Sandbox Code Playgroud)

我知道什么static const是什么但是什么是uint32_t什么0x1 << 0意思?是某种十六进制?

operators ios sprite-kit

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

Swiftlint 自动更正不修改文件

在运行swiftlint0.24.0版本时,报错。运行autocorrect表明文件已被更正。然而,在随后的证明运行中没有进行任何修改swiftlint

请参阅尝试检查并更正两个文件Player.swiftPrize.swift

MacBook-Pro-5: Developer$ swiftlint 
Loading configuration from '.swiftlint.yml'
Linting Swift files in current working directory
Linting 'Prize.swift' (1/2)
Linting 'Player.swift' (2/2)
Player.swift:26:19: warning: Operator Function Whitespace Violation: Operators should be surrounded by a single whitespace when defining them. (operator_whitespace)
Player.swift:27: warning: Line Length Violation: Line should be 120 characters or less: currently 131 characters (line_length)
Player.swift:39: warning: Line Length Violation: Line should be 120 characters or less: currently 147 …
Run Code Online (Sandbox Code Playgroud)

macos swift swiftlint

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

Swift 包清单属性“defaultLocalization”未设置

通过尝试 Swift Packages,我创建了一个新包。现有 Xcode 项目框架目标中的源文件和资源已移至新结构中。

尝试构建时,脚本显示错误:

manifest property 'defaultLocalization' not set; it is required in the presence of localized resources
Run Code Online (Sandbox Code Playgroud)

如何解决这个问题以便我可以创建 Swift 包?

xcode localization localizable.strings swift swift-package-manager

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

IOS:打开和关闭一些视图控制器

在我的应用程序中,我有以下配置来打开我的视图控制器:

当我写"pushViewController"时,我使用导航控制器,当我写"present"时,我使用了一个presentModalViewController.

firtsView -> (pushviewcontroller) -> secondOneView -> (present) -> thirdOneView -> (present) -> fourthView

firstView -> (pushviewcontroller) -> secondTwoView -> (present) -> thirdTwoView 
Run Code Online (Sandbox Code Playgroud)

这是我的应用程序来组织我的视图控制器的方案.然后我的问题是:

什么是从返回的路上"fourthView"(也就是,当我去从后"fourthView"),以"secondTwoView"

有办法吗?

xcode uiviewcontroller uinavigationcontroller presentmodalviewcontroller ios

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

collectionViewContentSize()vs contentSize

有什么区别

collectionViewController.collectionViewLayout.collectionViewContentSize()collectionViewController.collectionView.contentSize

你更喜欢用什么?

ios uicollectionview uicollectionviewcell uicollectionviewlayout swift

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

为什么无法在属性观察器 didSet 中更改 Swift 数组?

好像Swift的Array不会经过didSet,为什么呢?

var intArray: [Int] = [] {
    didSet {
        intArray += [0]
    }
}

if intArray.count == 0 {
    println("Why is intArray not being altered?")
}
Run Code Online (Sandbox Code Playgroud)

arrays observers swift didset

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

如何使用本地主机在 Web 浏览器中打开 Expo Web?

运行npm startexpo start启动项目如下:

\n\n
React  You can now view My React Native App in the browser.\n\n  Local:            http://localhost:19006/   On Your Network:  http://157.201.29.49:19006/\n\nNote that the development build is not optimized.\n\n \xe2\x80\xba To create a production build, run expo build:web  \xe2\x80\xba Press Ctrl+C to exit.\n\n Expo  Press ? to show a list of all available commands.\n
Run Code Online (Sandbox Code Playgroud)\n\n

通过按 \xe2\x80\x98w\xe2\x80\x99 启动 Expo 网络将打开 Chrome 浏览器,其中包含http://157.201.29.49:19006/建议的 IP 地址 URI。

\n\n

但由于办公室VPN的原因,Chrome浏览器无法解析该地址。错误是:

\n\n
\n

无法访问此站点\xe2\x80\x99
\n ERR_CONNECTION_TIMED_OUT

\n
\n\n …

vpn react-native expo expo-web

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

如何设置UIAlertView的高度和宽度?

我有一个UIAlertView图像和一个大按钮.

问题是默认值UIAlertView非常小.它的图像无法正常显示.

所以,我想增加高度和宽度UIAlertView.换句话说,我想创建一个自定义UIAlertView.这样做的方法是什么?

谢谢.

iphone uialertview

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

使用双间接指针分配将项目转换为ARC

我正在尝试将项目转换为ARC.该项目有一个Directed Acyclic Word Graph,它基本上意味着到处都有很多双重间接指针.

这对于转换为ARC来说是一个相当大的挑战,特别是一个问题让我目前难以接受.

这是场景.

假设你有一个NSString *:

NSString *b = [[NSString alloc] initWithString:@"hello"];
Run Code Online (Sandbox Code Playgroud)

您还有一个双间接类型:

__unsafe_unretained NSString **a;
Run Code Online (Sandbox Code Playgroud)

您想要将一个分配给另一个,如下所示:

    a = &b;
Run Code Online (Sandbox Code Playgroud)

这会产生转换错误:

error: assigning 'NSString *__strong *' to 'NSString *__unsafe_unretained *' changes retain/release properties of pointer
Run Code Online (Sandbox Code Playgroud)

更改b__unsafe_unretained不工作.我也尝试了各种桥接演员.我错过了一些明显的东西吗?

有任何想法吗?

谢谢!

pointers objective-c automatic-ref-counting unsafe-unretained

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