Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Glimm
Jul 27, 2005

Time is only gonna pass you by

Doctor w-rw-rw- posted:

Anyone else able to reproduce?

Yep, crashed mine right away

Adbot
ADBOT LOVES YOU

Glimm
Jul 27, 2005

Time is only gonna pass you by

I'm a bit confused with the Swift closure syntax myself.

For example, when Xcode autocompletes ReactiveCocoa's RACSignal.createSignal it generates:

code:
RACSignal.createSignal(didSubscribe: ((RACSubscriber!) -> RACDisposable!)?)
I'm sure I'm missing something, but I don't know what to do with that, this works though:

code:
RACSignal.createSignal({(RACSubscriber) -> RACDisposable in
       	return RACDisposable(block: {
	})
})
The ObjC definition of createSignal is:

code:
+ (RACSignal *)createSignal:(RACDisposable * (^)(id<RACSubscriber> subscriber))didSubscribe;
Is this just weirdness in the autocompletion, or am I missing how to use the autocompleted code somehow?

Glimm
Jul 27, 2005

Time is only gonna pass you by

I think I've run into a Swift issue but I'm not sure if it is just me missing something.

This works:
code:

    init(dictionary: [String: AnyObject]) {

        if let startDate: AnyObject = dictionary["startDate"]? {
            if let startDateString = startDate as? String {
                ...
            }
        }
    ...
    }
but this fails to compile, with this error:
Type 'DictionaryIndex<String, AnyObject>' does not conform to protocol 'StringLiteralConvertible'

code:
    init(dictionary: [String: AnyObject]) {

        if let startDate = dictionary["startDate"]? as? String {
           ...
        }
     ...
     }
It seems to me like they should be doing the same thing. Should I be filing a radar?

Glimm
Jul 27, 2005

Time is only gonna pass you by

Did += for Array just die with the new beta?

:cry:

Glimm
Jul 27, 2005

Time is only gonna pass you by

Is this a Swift issue or something I'm doing wrong?

code:
let error = NSError()
println("error domain: \(error.domain)") // EXC_BAD_ACCESS

This fails to compile entirely as domain is not an optional:

code:
        if let domain = error.domain {

        }
I think one shouldn't be making NSError's without a domain and code (the NSError that brought this to my attention is from someone elses test case), but the fact that it is possible makes me think I should be able to handle it gracefully. Am I missing something simple here?

Glimm
Jul 27, 2005

Time is only gonna pass you by

rjmccall posted:

This seems like an SDK issue. When Swift imports an ObjC class, it gets all the initializers declared anywhere in its class hierarchy. This is the right default, because it's quite common for ObjC classes to inherit initializer signatures from their superclasses without explicitly redeclaring them in their @interfaces. In some cases, however, this is problematic, because the class's invariants require it to be initialized in a certain, subclass-specific way. That's what's happening here, and the right fix is probably for NSError to redeclare -init and mark it unavailable.

In the meantime, yeah, you just need to be careful to not create NSErrors that way.

OK, good to know - thanks!

Glimm
Jul 27, 2005

Time is only gonna pass you by

fleshweasel posted:

More JSON difficulty here. I have a JSON object that I successfully converted to Array<Dictionary<String, AnyObject>>. When I say something like:

code:
self.aStringProperty = json["key"]
I get a complaint that (String, AnyObject) is not convertible to String. I would at LEAST expect that it say AnyObject is not convertible to String. Why is it thinking that the subscript notation is giving the whole key/value pair?

It looks to me like json is an array there? Do you mean json[0]["key"]?

Glimm
Jul 27, 2005

Time is only gonna pass you by

fleshweasel posted:

I'm having difficulty getting this extension method working.

The error is: Cannot invoke '!=' with an argument list of type (T, T). I thought the point of that <T: Equatable> was to address that.

I think the extension doesn't know that self is an Array<T>, so maybe:

code:
extension Array {
    func compareTo<T: Equatable>(other: [T]) -> Bool {
        for (key, value) in enumerate(self) {
            if let value = value as? T {
                let otherValue: T = other[key]
                if value != otherValue {
                    return false
                }
            } else {
                return false
            }
        }
        return true
    }
}
edit: oh yeah some bounds checking would be good too

Glimm fucked around with this message at 14:34 on Sep 29, 2014

Glimm
Jul 27, 2005

Time is only gonna pass you by

dukerson posted:

So not sure if this is the best place for this, but I haven't been able to find any answers elsewhere:

My Swift port of an existing Obj-C app keeps on getting rejected from the App Store due to crashing. Specifically, the following excerpt from the crash log provided by the App Store:

pre:
Dyld Error Message:
  Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /private/var/mobile/Containers/Bundle/Application/ED6A7194-EAD0-4FB6-8E81-C4C987E60E08/<AppName>.app/<AppName>
  Reason: no suitable image found.  Did find:
	/private/var/mobile/Containers/Bundle/Application/ED6A7194-EAD0-4FB6-8E81-C4C987E60E08/
<AppName>..app/Frameworks/libswiftCore.dylib: mmap() error 1 at address=0x100168000, size=0x00194000 segment=__TEXT in Segment::map() 
mapping /private/var/mobile/Containers/Bundle/Application/ED6A7194-EAD0-4FB6-8E81-C4C987E60E08/<AppName>.app/Frameworks/libswiftCore.dylib
  Dyld Version: 353.5
I'm unable to reproduce this issue on my end via phone or Simulator (even creating the Archive, submitting it as an Ad Hoc .ipa, and installing it onto my phone works completely fine) -- I'm guessing I'm missing something very dumb? Has anyone run into anything similar? It looks like it's unable to find the swift core libraries, or something similar?

Might be related to this: https://twitter.com/rustyshelf/status/518205886703996928

Looks like apps recently submitted that use frameworks are crashing on launch.

Glimm
Jul 27, 2005

Time is only gonna pass you by

playground tough posted:

If I work with swift, am I going to have an easier time building my app coming from a java & c background than with this react bullshit? Thanks.

In my opinion, yes. React Native is cool but has kind of a steep learning curve if you're not already familiar with JavaScript / web tools / React itself.

Glimm
Jul 27, 2005

Time is only gonna pass you by

status posted:

So I just got this neat new job that I start in a couple of weeks. The company just recently (late last year-ish?) started doing everything Swift. That's great, but I don't know Swift at all. I tried watching those Stanford lectures but they were the most boring loving thing ever. I've been a full time iOS developer for a bunch of years, so I don't need to learn what Autolayout is or how to use a tableview. I just need to learn some Swifty stuff. What's the hot poo poo as far as books go? The OP is pretty empty.

Have you looked at the books Apple provides on iBooks?

https://itunes.apple.com/us/book/swift-programming-language/id881256329?mt=11
https://itunes.apple.com/us/book/using-swift-cocoa-objective/id888894773?mt=11

They're very informative. They aren't super jazzed up or anything though, I don't know how boring you might find them.

Adbot
ADBOT LOVES YOU

Glimm
Jul 27, 2005

Time is only gonna pass you by

Should I be able to replace Cocoapods/Carthage with Swift Package Manager once Xcode 9 is released?

I haven't looked into SPM in awhile, last I remember it didn't work with iOS at all and maybe not with Objective-C laden libraries.

  • Locked thread