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.
 
  • Post
  • Reply
Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
IIRC CoreLocation will take location data from a MiFi approved accessory, you just need to engage the right people. Let me know if that doesn’t work and I’ll see if I can track someone down.

Adbot
ADBOT LOVES YOU

fankey
Aug 31, 2001

I just updated to XCode 9.2 and I'm running into a lot of issues with the simulator that I'm pretty sure didn't occur in previous versions. I haven't narrowed things down to simple test cases yet but one thing I've noticed is that if I change the UI via a touch interaction ( automatically scrolling a scroll viewer, setting UIView.hidden, etc ) things seem to lag one update when running in the simulator but function just fine on real devices. I'm totally open to the problem being in my code but I'm curious if anyone else has seen weird performance using the new simulators. I'm also seeing a bunch of app crashes in the simulator that I can't reproduce on real devices.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Shot in the dark but I’ve seen weirdness go away after deleting and recreating simulators.

fankey
Aug 31, 2001

Do you mean deleting and readding via the 'Add Additional Simulators..' item at the end of the simulators list? I tried removing and adding one and it didn't fix the issue. Do I need to remove them all?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Yeah that’s it. It’s definitely a "turn it off and on again" suggestion, not surprised it doesn’t work.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

fankey posted:

I just updated to XCode 9.2 and I'm running into a lot of issues with the simulator that I'm pretty sure didn't occur in previous versions. I haven't narrowed things down to simple test cases yet but one thing I've noticed is that if I change the UI via a touch interaction ( automatically scrolling a scroll viewer, setting UIView.hidden, etc ) things seem to lag one update when running in the simulator but function just fine on real devices. I'm totally open to the problem being in my code but I'm curious if anyone else has seen weird performance using the new simulators. I'm also seeing a bunch of app crashes in the simulator that I can't reproduce on real devices.

Do you have an Intel HD 3000 GPU or something similar?

LP0 ON FIRE
Jan 25, 2006

beep boop
Anyone know of any way to create a lossy gif in Swift? kCGImagePropertyGIFDictionary doesn't seem to have many options. So far I've resorted to making the image smaller and skipping frames from my list of 31 images, which isn't exactly preferable.

Doctor w-rw-rw-
Jun 24, 2008
GIF is not a lossy file format. If you want a lossy encoding for what is essentially video then just use a video encoding.

LP0 ON FIRE
Jan 25, 2006

beep boop
Oh really? Maybe the pallet limitations is all I’m looking for. Do you think I should go from a lossy compressed video format to gif to easily get a more reduced set of colors?

Unfortunately my app uses a lot of colors since the filter fades images to different color hues. I wanted a gif option so people could easily share them on image upload sites like imgur.

e: The video thing doesn't seem right. I don't know what I was thinking. Anyway I think I'll figure out how to reduce the color indices.

LP0 ON FIRE fucked around with this message at 19:46 on Jan 31, 2018

fankey
Aug 31, 2001

Simulated posted:

Do you have an Intel HD 3000 GPU or something similar?

As a matter of fact yes - MacBook Air Mid 2011.

LP0 ON FIRE
Jan 25, 2006

beep boop
Here's the lossy compression property for gifs I was looking for: https://developer.apple.com/documentation/imageio/kcgimagedestinationlossycompressionquality

Can't seem to make it make any noticeable visual or file size changes though.

e: I guess while making the gif I’m just going to convert the source UIImage into a lower quality image format. I think that’s what you were getting at, I just thought there would be a more direct approach while composing a gif!

LP0 ON FIRE fucked around with this message at 00:00 on Feb 1, 2018

Doctor w-rw-rw-
Jun 24, 2008
GIF pixel data is compressed losslessly. That option will not work. Your only options for GIF compression is to scale down or to decrease entropy (i.e. reduce palette) so that the LZW compression is more effective. Core Graphics doesn't offer you a way to do this easily, unfortunately, though there are utilities which do GIF optimizations - maybe check how they work.

If mp4 is an option, it's still not ideal because as of a month ago, Imgur doesn't support mp4 uploads. Though it's possible through their desktop site using a private API...so maybe some reverse engineering would make that a possible, if unreliable, solution.

LP0 ON FIRE
Jan 25, 2006

beep boop
I was able to manipulate each UIImage that was made into a gif by quantizing the pixel color data and converting back into a UIImage. I found this Stack Overflow and used almost all the code in the answer, aside from a rounding function that caps off at 255, and replaced the if statement that original checked for black and turned it to red.

Quantizing the color made a huge noticeable difference in the file size, but it is very slow, memory intensive and power hungry. I made the max width 200px and it speeds things up quite a bit and makes the file size more realistic for image upload sites. I'm probably going to make it run as a background process instead, though that will probably sacrifice the speed a bit.

My edited for loop:

code:
for row in 0 ..< Int(height) {
   for column in 0 ..< Int(width) {
      let offset = row * width + column
      pixelBuffer[offset] = RGBA32(red: quantizeColor(Double(pixelBuffer[offset].redComponent), toNearest:30.0),
                                                          green: quantizeColor(Double(pixelBuffer[offset].greenComponent), toNearest:30.0),
                                                          blue: quantizeColor(Double(pixelBuffer[offset].blueComponent), toNearest:30.0),
                                                          alpha: 255)
   }
}
And the quantize color function:

code:
func quantizeColor(_ x : Double, toNearest : Double) -> UInt8 {
   let result = Int(toNearest) * Int((x / toNearest).rounded())
   return UInt8(result > 255 ? 255 : result)
}

LP0 ON FIRE fucked around with this message at 21:39 on Feb 1, 2018

SaTaMaS
Apr 18, 2003
edit: determined what I wanted to do wasn't possible

SaTaMaS fucked around with this message at 04:02 on Feb 4, 2018

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

fankey posted:

As a matter of fact yes - MacBook Air Mid 2011.

It’s a GPU driver bug. The driver decides that sometimes you didn’t really need that update and drops it on the floor. I don’t have a workaround for you at the moment, other than using a metal-capable Mac or one with a newer Intel GPU.

lord funk
Feb 16, 2004

Can anyone get an autocompleted Swift initializer for things like UIView, CGRect, etc., the first time? Like, no pressing backspace, no arrowing through autocomplete menus?

If you know a trick please let me know because :mad:

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Sometimes it helps to type a closing parenthesis then move back one and hit escape. Not often, but sometimes.

dc3k
Feb 18, 2003

what.
I always do ‘Class.init(‘ and it autocompletes properly. Then just delete the ‘.init’ when I’m done.

ManicJason
Oct 27, 2003

He doesn't really stop the puck, but he scares the hell out of the other team.
I have OK luck if I pause immediately after the (. If you so much as breathe at that point, you will never find the initializers.

lord funk
Feb 16, 2004

dc3k posted:

I always do ‘Class.init(‘ and it autocompletes properly. Then just delete the ‘.init’ when I’m done.

Okay so this is the kind of autocomplete I like (minus the deleting the '.init' part afterwards). You just keep typing arguments that are present in the rest of the function and it fills it in without waiting or arrowing through options.

ManicJason posted:

I have OK luck if I pause immediately after the (. If you so much as breathe at that point, you will never find the initializers.

Yeah but you still have to arrow down through useless crap to find the one you want.

Seriously considering changing my personal style guide to include '.init' just to type normally.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
I checked this thread because I'm starting to dive into ARKit but I haven't seen a whole lot of chatter about it. Is there a separate thread for that kind of stuff?

lord funk
Feb 16, 2004

IAmKale posted:

I checked this thread because I'm starting to dive into ARKit but I haven't seen a whole lot of chatter about it. Is there a separate thread for that kind of stuff?

Nah you're in the right place. I'd love to hear updates from you about ARKit, as there's a multimedia guy down the hall that does AR stuff but using Oculus / Unity stuff.

TheReverend
Jun 21, 2005

dc3k posted:

I always do ‘Class.init(‘ and it autocompletes properly. Then just delete the ‘.init’ when I’m done.

lol, I thought I was the only one who did this.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe

lord funk posted:

Nah you're in the right place. I'd love to hear updates from you about ARKit, as there's a multimedia guy down the hall that does AR stuff but using Oculus / Unity stuff.
Hopefully I won't make you wait too long. This is my first foray into iOS development and so I'm reading through Apple's The Swift Programming Language book first to get a handle on Swift (I have plenty of Python and Java experience so it shouldn't take too long...)

I'm curious, though, if this is an error with the book, or something I'm doing wrong. In the section titled A Swift Tour, it tells me I can create an empty dictionary with [:] when type information can be inferred. However, doing this in a Swift 4 playground yields an Empty collection literal requires an explicit type error. Is this style of dictionary initialization deprecated in Swift 4?

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

IAmKale posted:

when type information can be inferred.

Type information can't be inferred in that case. All the compiler has to work with is var and the variable's name, nothing about the type. Now, if it was a function argument, or if you were assigning the dictionary literal to an already declared and initialized variable, it would work

IAmKale
Jun 7, 2007

やらないか

Fun Shoe

hackbunny posted:

Type information can't be inferred in that case. All the compiler has to work with is var and the variable's name, nothing about the type. Now, if it was a function argument, or if you were assigning the dictionary literal to an already declared and initialized variable, it would work
Ah, that only works to reset an existing dictionary - I see! Taking a look at that section of the quickstart again, this must be what they were really showing off:



Thanks for the clarification!

lord funk
Feb 16, 2004

Yeah you'd want

code:
var occupations: [String : String] = [:]
if you wanted it to be empty at the declaration.

Doh004
Apr 22, 2007

Mmmmm Donuts...
Or!

code:
var occupations = [String: String]()
(I'm not saying do one over the other, just felt like contributing...)

Doh004 fucked around with this message at 22:38 on Feb 6, 2018

lord funk
Feb 16, 2004

oooooooor

code:
let occupations = Dictionary<String,String>()
Swift! The language we can't loving make up our mind on :allears:

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Why is it so difficult to convince people that Xcode crashes need to be reported to Apple and not us?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Who is us

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Plorkyeran posted:

Why is it so difficult to convince people that Xcode crashes need to be reported to Apple and not us?

Why would people be reporting Xcode crashes to you in the first place?

Do you produce some sort of “Xcode plug-in?” If so, then crashes should be reported to you, as plug-ins aren’t supported by Apple and are quite likely to have a variety of blatant or subtle problems resulting from using reverse-engineered internals that can change literally between individual builds.

Doc Block
Apr 15, 2003
Fun Shoe
I think he means this thread

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
No. We have a library and people like to tell us about how Xcode crashed while they were debugging something using our library and expect us to do something about this.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Plorkyeran posted:

No. We have a library and people like to tell us about how Xcode crashed while they were debugging something using our library and expect us to do something about this.

Yeah, that’s entirely on the IDE and debugger to deal with.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
Why is Xcode messing up indentation when I try to write out a switch statement?


(Apologies for the slow, low-quality gif, I have no idea what a good MP4 hosting site is for screen recordings like this)

Edit: I guess it's just a Thing with Xcode that you suckers have been living with all this time. And now I'm a sucker, too, because Swift is actually kind of fun :qq:

IAmKale fucked around with this message at 06:30 on Feb 7, 2018

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

IAmKale posted:

Why is Xcode messing up indentation when I try to write out a switch statement?


(Apologies for the slow, low-quality gif, I have no idea what a good MP4 hosting site is for screen recordings like this)

Edit: I guess it's just a Thing with Xcode that you suckers have been living with all this time. And now I'm a sucker, too, because Swift is actually kind of fun :qq:

It's apparently a convention to have switch and case on the same indent level. Eclipse does it too.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

IAmKale posted:

Why is Xcode messing up indentation when I try to write out a switch statement?


(Apologies for the slow, low-quality gif, I have no idea what a good MP4 hosting site is for screen recordings like this)

Edit: I guess it's just a Thing with Xcode that you suckers have been living with all this time. And now I'm a sucker, too, because Swift is actually kind of fun :qq:

That’s the convention for switch/case formatting.

Also, for something like this you can make a raw-representable enum rather than create functions to convert between your type and strings.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe

eschaton posted:

That’s the convention for switch/case formatting.

Also, for something like this you can make a raw-representable enum rather than create functions to convert between your type and strings.

Aha, you're absolutely right, that's way less boilerplate for getting back a string value for a particular enum:

code:
enum SomeVals: String {
    case fizz = "fizz"
    case buzz = "buzz"
}

SomeVals.fizz.hashValue // 0
SomeVals.fizz.rawValue // "fizz"
SomeVals.buzz.hashValue // 1
SomeVals.buzz.rawValue // "buzz"
Alright, I managed to finish the QuickStart section tonight. I feel generally confident that I've grasped the basics, but there's still a sense of unease I get from a lot of inference that I'm not used to coming from Python and JavaScript. I'm talking about things such as "omitting" self within a class when setting an internal variable or executing a method, or being able to use things like case .fizz in a switch statement within an enum. The feeling will pass, though, so this is a temporary gripe.

I feel as though I know enough Swift to at least get started dabbling with ARKit, though. And I can always peruse the rest of this (massive!) reference book later, or whenever I get stuck, whichever comes first :v:

Thanks for the tips so far. I know I'll be back with more as I dive into ARKit, SceneKit, and SpriteKit for the first time, but I'm feeling optimistic!

Adbot
ADBOT LOVES YOU

Doh004
Apr 22, 2007

Mmmmm Donuts...

lord funk posted:

oooooooor

code:
let occupations = Dictionary<String,String>()
Swift! The language we can't loving make up our mind on :allears:

Brings me back to my C# days :allears: . We initially did that syntax when we started our app back in 2015 before standardizing things. I still find remnants in helpers that we were too lazy to update.

IAmKale posted:

Aha, you're absolutely right, that's way less boilerplate for getting back a string value for a particular enum:

code:
enum SomeVals: String {
    case fizz = "fizz"
    case buzz = "buzz"
}

SomeVals.fizz.hashValue // 0
SomeVals.fizz.rawValue // "fizz"
SomeVals.buzz.hashValue // 1
SomeVals.buzz.rawValue // "buzz"
Alright, I managed to finish the QuickStart section tonight. I feel generally confident that I've grasped the basics, but there's still a sense of unease I get from a lot of inference that I'm not used to coming from Python and JavaScript. I'm talking about things such as "omitting" self within a class when setting an internal variable or executing a method, or being able to use things like case .fizz in a switch statement within an enum. The feeling will pass, though, so this is a temporary gripe.

I feel as though I know enough Swift to at least get started dabbling with ARKit, though. And I can always peruse the rest of this (massive!) reference book later, or whenever I get stuck, whichever comes first :v:

Thanks for the tips so far. I know I'll be back with more as I dive into ARKit, SceneKit, and SpriteKit for the first time, but I'm feeling optimistic!

You can still use self, really just comes with your code style guide. That said, we don't use it because it highlights when we need to use capture lists in closures: https://stackoverflow.com/questions/39465726/capture-list-in-swift

Doc Block posted:

I think he means this thread

I love the Facebook vs Apple fights ITT.

Doh004 fucked around with this message at 12:59 on Feb 7, 2018

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply