小编vrw*_*wim的帖子

如何为CoreData中的NSManaged属性赋予初始值?

我用Swift.我有一个CoreData,它有一个名为days的字符串属性.我想为此分配一个默认值.我在我的CoreData模型类中尝试了它,但它给出了一个错误,说"NSManaged属性不能有初始值".

这是我试过的.

@NSManaged var daysAvailable:String = "M"
Run Code Online (Sandbox Code Playgroud)

core-data ios swift

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

我如何使用这个私有API?

我找到了这个类PSCellularDataSettingsDetail及其方法+(void)setEnabled:(BOOL)enabled;,我认为它会给我我需要的东西,即访问移动数据设置.

我通过打开编译Preferences.framework使用找到了这个方法class-dump-z.

现在我找到了这个答案并尝试以这种方式访问​​类和方法,但该类也是私有的.如何打开这个类到Xcode?

iphone-privateapi ios

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

Python 2 与 Python 3 导入

我有一个用 Python 编写的脚本。作者决定使用仅在 Python 3 中可用的新功能,因此我不得不更新我的版本。

现在我遇到了麻烦,因为脚本在导入语句上崩溃,所以我决定进行一些调试。我得出的结论是,我的 Python 3 无法ImagePIL.

在 Python 2 中:

Python 2.7.10 (default, Aug 22 2015, 20:33:39) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
Run Code Online (Sandbox Code Playgroud)

不会给出错误,但在 Python 3 中:

Python 3.5.0 (v3.5.0:374f501f4567, Sep 12 2015, 11:00:19) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from …
Run Code Online (Sandbox Code Playgroud)

python python-import python-2.7 pillow python-3.5

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

我应该使用田地还是财产?

首先,我已经阅读了询问字段和属性之间差异的问题,我知道它的用途.

现在回答我的问题,我想创建一个属性,我确信get和set都是空的,所以我这样做get; set;.一切都很好.但是现在我意识到我刚刚创建了一个带有大写名称的公共领域,它在各方面都是相同的.

即使是使用它的论点,因此未来的代码也不能依赖于实现,因为我可以简单地将其作为属性并实现getter或setter.字段和属性的语义在它定义的类之外是相同的.

所以我的问题是,当一个房产只是使用时,我应该使用一个字段或一个属性get;set;吗?

所以这:

public IEnumerable<string> Products;
Run Code Online (Sandbox Code Playgroud)

在各方面都是相同的:

public IEnumerable<string> Products { get; set; }
Run Code Online (Sandbox Code Playgroud)

c# field properties

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

UIRefreshControl显示在UICollectionViews Cells之上

我使用以下代码创建UIRefreshControl:

_refreshControl = new UIRefreshControl();
_refreshControl.ValueChanged += RefreshTriggered;
_collectionView.InsertSubview(_refreshControl, 0);
Run Code Online (Sandbox Code Playgroud)

而且我不知道为什么UIRefreshControl会被UICollectionViewCells 吸引.

以下是UICollectionView我刚添加刷新控件时的子视图:

[0]: {<UIRefreshControl: 0x7c132fe0; frame = (0 0; 594 60); hidden = YES; autoresize = W; layer = <CALayer: 0x7c133250>>}
[1]: {<UIImageView: 0x79f8a5d0; frame = (3 588.5; 588 2.5); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0x79f89a70>> - (null)}
[2]: {<UIImageView: 0x79fab7d0; frame = (588.5 584; 2.5 7); alpha = 0; opaque …
Run Code Online (Sandbox Code Playgroud)

c# ios xamarin uicollectionview

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

为什么Xcode告诉我最后一个案例永远不会被执行?

对于这里在计算器上另外一个问题,我在输入斯威夫特一些测试代码,让我吃惊它告诉我,过去的情况下,将永远不会被执行(具有.B, .C, .D),任何人有什么想法?

func test(someEnum: EnumType) {
    switch someEnum {
    case .A:
        someMethodSpecificToA()
        fallthrough
    case .B, .C, .D:
        someMethodSpecificToTheseThreeLetters()
        fallthrough
    case .E:
        someMethodSpecificToE()
        fallthrough
    case .A, .E:
        aMethodIShouldCallOnVowels()
    case .B, .C, .D:
        aMethodIShouldCallOnAllConsonants()
    }
}
Run Code Online (Sandbox Code Playgroud)

xcode switch-statement swift

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

来自URL的图像请求失败

我有以下代码:

func getImage(urlString: String, completionHandler: UIImage -> Void) -> NSURLSessionTask {

    let request = NSMutableURLRequest(URL: NSURL(fileURLWithPath: urlString)!)

    println("Executing image request: \(urlString)")

    return session.dataTaskWithRequest(request) {
        data, response, error in
        if error != nil {
            println("\tGET request failed: \(error!)")
        } else {
            println("\tGET request succeeded!")
            let response = response as NSHTTPURLResponse
            if response.statusCode == 200 {
                let image = UIImage(data: data)
                dispatch_async(dispatch_get_main_queue()) { // dispatch naar main thread (main_queue is thread# van main thread van app)
                    completionHandler(image!)
                }
            }
        }
    }
} …
Run Code Online (Sandbox Code Playgroud)

uiimage ios swift

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

半透明背景和不透明的前景wpf

我目前有以下xaml代码:

<Grid
    Name="rootGrid"
    Opacity=".25"
    Background="Black"
    HorizontalAlignment="Stretch"
    VerticalAlignment="Stretch">
    <Border
        Background="Black"
        Margin="120">
        <Grid
            Background="White"
            Margin="8">
            <TextBlock
                Name="popupContent">
                Test
            </TextBlock>
            <Button
                Click="Button_Click">
                Test
            </Button>
        </Grid>
    </Border>
</Grid>
Run Code Online (Sandbox Code Playgroud)

目前,该Opacity设置Grid也适用于其子女.

我只希望将此不透明度应用于其背景颜色,以实现变暗效果,而不是前景.我怎样才能做到这一点?

c# wpf uwp

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

在Ruby中,什么相当于Java在cowork情境中限制访问源的技术?

在Java中编译定义类的.java文件时,它会创建一个.class文件.如果您向同事提供这些类文件,则他们无法修改您的来源.您还可以将所有这些类文件捆绑到一个jar文件中,以便更整齐地将其打包并将其作为单个库分发.

当你想与你的同事分享你的功能但你不希望他们能够修改源代码时,Ruby是否有这些功能(除非他们要求你提供实际的.rb源文件并告诉你他们想要更改)?

ruby

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

如何在C#中自动生成logger调用到源代码中?

我想在方法体中产生什么:

private void SomeMethod()
{
Logger.Log("Entering SomeMethod.");

// do stuff here

Logger.Log("Exiting SomeMethod.")
}
Run Code Online (Sandbox Code Playgroud)

有没有可以为我生成的工具?如果没有,我想自己实现一个,那么我从哪里开始,我应该考虑使用哪个库来识别c#源代码中的方法?简单的正则表达式应该足够了吗?

c# logging code-generation

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

使用Task.Result锁定应用程序的API调用

我有一段C#代码(它在Xamarin应用程序中,但我不认为这是相关的)初始化我的应用程序.它是这样的:

class AppController {
    public override void InitializeApp() {
        // Do stuff to initialize services & database
        checkNeedsUpdates();
    }

    void checkNeedsUpdates() {
        Task.Run(() => {
            string json = API.Call("versions").Result
            // It never gets here
        });
    }
}

class API {
    HttpClient client;

    public Task<string> Call(string endpoint) {
        // Setup headers and access token things before handing over to POST function
        return Post(/*params*/);
    }

    public async Task<string> Post(/*params*/) {
        // Setup
        return await Request(/*params*/);
    }

    public async Task<string> Request(/*params*/) {
        HttpRequestMessage …
Run Code Online (Sandbox Code Playgroud)

c# task async-await

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

过滤字典数组 - SWIFT

我有以下数组:

[[user1ID: NSDate], [user2ID: NSDate], [user3ID: NSDate]]
Run Code Online (Sandbox Code Playgroud)

它可以被过滤掉,所以我只能得到字典user2ID吗?

arrays dictionary filter swift

-2
推荐指数
1
解决办法
3174
查看次数

What does the dollar sign do in this example?

This tutorial by Apple about SwiftUI uses a dollar sign to bind data, and I‘m having trouble finding more information about this data binding in SwiftUI.

Is this some sort of inout type parameter? That uses the ampersand to pass it on.

swift swiftui combine

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