|
LP0 ON FIRE posted:why didn't they just make it Swift, or have the language know to do whatever it needs to do without adding "@obj"? Maybe there's not a good reason..
|
# ? Oct 17, 2017 21:48 |
|
|
# ? May 22, 2024 19:22 |
|
ManicJason posted:That was the case before Swift 4. Here is the reasoning for the change. Axiem posted:Things with @objc are visible to Objective-C; things without it aren't. This has effects in how it's compiled under the hood in ways that people more knowledgable than I can explain, but it basically comes down to "avoiding @objc will make more performant code". ManicJason posted:That was the case before Swift 4. Here is the reasoning for the change. Thanks. Makes me wonder how much longer that will need to be used often, and realize that Swift is still very much in it's infancy. Still Swift 3 to 4 has some drastic changes, and pretty much everything I look up has deprecations all over it. As an unimportant, irrelevant side note, right now I'm struggling with optionals on AVCaptureSession (especially with canAddInput) and what delegate will be set on capturePhoto on AVCapturePhotoOutput. I might make a post about it later, but I think I may just need to understand all this stuff better first.
|
# ? Oct 17, 2017 23:01 |
|
LP0 ON FIRE posted:Finally getting my hands dirty into Swift. I'm curious if there's any convincing reason behind prepending "@obj" before some of the functions, for instance ones that are called by Timers (I think because of the selector parameter). I know it's using Obj-C, but why did they design it this way? It seems confusing to remember that some calls must have this. So why didn't they just make it Swift, or have the language know to do whatever it needs to do without adding "@obj"? Maybe there's not a good reason.. As for your particular example, there’s a block-based Timer initializer available in Swift, in case you find it useful. pokeyman fucked around with this message at 03:31 on Oct 18, 2017 |
# ? Oct 17, 2017 23:03 |
|
pokeyman posted:As for your particular example, there’s a block-based timer Timer initializer available in Swift, in case you find it useful. Ah, good to know! Makes more sense now.
|
# ? Oct 18, 2017 02:13 |
|
For whatever reason there’s been a block-based timer function on CFRunLoopTimer for awhile, but never on NSTimer. Always thought that was a strange omission. Happy to delete that NSTimer category from my utils.m now that the Swift overlay has it.
|
# ? Oct 18, 2017 03:30 |
|
Here's my AVCapturePhotoOutput problem. For AVCapturePhotoOutput, I have no idea what the delegate should be set to. Every combination I tried returns an error or crashes with an exception "Could not cast value of type 'myApp.MainViewController' to 'AVCapturePhotoCaptureDelegate'". The line is self.stillImageOutput.capturePhoto(with: settings, delegate: self as AVCapturePhotoCaptureDelegate) "self" - returns error "Argument type 'MainViewController' does not conform to expected type 'AVCapturePhotoCaptureDelegate'" "self as! AVCapturePhotoCaptureDelegate" - crashes immediately "Could not cast value of type 'MyApp.MainViewController' to 'AVCapturePhotoCaptureDelegate'." "self as AVCapturePhotoCaptureDelegate" - returns error "'MainViewController' is not convertible to 'AVCapturePhotoCaptureDelegate'; did you mean to use 'as!' to force downcast?" I've also tried setting a constant for my delegate: let appDelegate = UIApplication.shared.delegate as! AppDelegate Then trying different combinations with it such as: self.stillImageOutput.capturePhoto(with: settings, delegate: AppDelegate as AVCapturePhotoCaptureDelegate) Current implementation (minus viewDidLoad and some other things) where setting it to 'self as AVCapturePhotoCaptureDelegate' is giving me an error (described above): code:
|
# ? Oct 19, 2017 18:43 |
|
Your class has to adopt the AVCapturePhotoCaptureDelegate protocol, which means declaring it and then implementing all required methods and any optional methods you need. No different than Objective-C. IDK Swift, but probably something like Swift code:
|
# ? Oct 19, 2017 20:45 |
|
Doc Block posted:Your class has to adopt the AVCapturePhotoCaptureDelegate protocol, which means declaring it and then implementing all required methods and any optional methods you need. No different than Objective-C. Thank you
|
# ? Oct 19, 2017 22:14 |
|
Let's talk CFI, shall we? Now, Apple men present, I know that CFI is not officially supported on iOS, but the toolchain supports it, and I figured it couldn't hurt having that extra layer of security in my shipped binaries. Granted, as implemented by the Xcode command line tools, all it does is hit a breakpoint on violations, with no diagnostic message of any kind. To make it even less pleasant to diagnose violations, it requires link-time optimization, which inlines functions so aggressively I always prayed I'd never have to deal with a genuine CFI crash. My prayers fell on deaf ears Disclaimer: I'm going to disable CFI, I've already chosen to, you don't need to tell me. All I want to know is: is this a compiler bug, or is this a compiler bug? (I know it is, because before I upgraded Xcode, the same code didn't crash). The code that crashes is: code:
|
# ? Oct 20, 2017 11:03 |
|
Update: Maybe you don't need to specify DISPATCH_QUEUE_SERIAL anymore? I'm afraid this is wrong since it's so different, but I now have this without an error:code:
Anyone know what's going on here? I find this error confusing and unhelpful. It has a problem with DISPATCH_QUEUE_SERIAL: "Cannot convert value of type '()' to expected argument type '__OS_dispatch_queue_attr?'" code:
LP0 ON FIRE fucked around with this message at 17:39 on Oct 25, 2017 |
# ? Oct 25, 2017 17:32 |
|
Try passing nil or .serial as the second parameter to DispatchQueue.init
|
# ? Oct 25, 2017 19:29 |
|
pokeyman posted:Try passing nil or .serial as the second parameter to DispatchQueue.init Update: I also see a way of passing a label and attributes, but ".serial" does not seem to be supported any longer. Other users say this is default, but I wonder how you'd specify it anyway? There doesn't seem to a list on the Apple website https://developer.apple.com/documentation/dispatch/dispatchqueue.attributes code:
Old: (Edit, didn't realize there was another init method!) What would that look like? The params are label, qos, attributes, autoreleaseFrequency and target. It doesn't seem like I'd need some other parameters, so I guess I'd pass nil, but qos (the second parameter) doesn't let me pass nil or .serial. I'm unsure if setting it up with DispatchQueue.init with the 5 parameters it has to do with the problem I'm having right now which is captureOutput is not being called. LP0 ON FIRE fucked around with this message at 21:43 on Oct 25, 2017 |
# ? Oct 25, 2017 21:05 |
|
I just popped this in a playground and it did the thing:code:
|
# ? Oct 26, 2017 01:02 |
|
pokeyman posted:I just popped this in a playground and it did the thing: Cool, I didn't think of that! Works too. I just discovered my main problem was that my captureOutput function was written as pre-swift 3 - thus not being called Should have been: code:
|
# ? Oct 26, 2017 18:16 |
|
I’m really excited to have the CIFilters work though the camera in real time. I’m curious how the filters are written, so eventually I’ll find the source of those. (But seriously, where is the source for these?) I’m just using the built in ones that Apple wrote for now. LP0 ON FIRE fucked around with this message at 21:04 on Oct 26, 2017 |
# ? Oct 26, 2017 20:58 |
|
I don’t think the source for those filters is available. Though I’d imagine if they’re just compiled shaders somewhere you could probably decompile them somehow? edit: also yay for getting it working!
|
# ? Oct 27, 2017 01:01 |
|
pokeyman posted:I don’t think the source for those filters is available. Though I’d imagine if they’re just compiled shaders somewhere you could probably decompile them somehow? Wow really? I’m really stupid and I’m genuinely curious how this works. Could they possibly be some tiny compiled programs of the shaders somewhere and then they get compiled with the code or something? I thought everything you include is available somewhere.
|
# ? Oct 27, 2017 05:53 |
|
LP0 ON FIRE posted:Wow really? I’m really stupid and I’m genuinely curious how this works. Could they possibly be some tiny compiled programs of the shaders somewhere and then they get compiled with the code or something? I thought everything you include is available somewhere. Er, you don’t think UIKit source code is included with Xcode and the iOS SDK, do you?
|
# ? Oct 27, 2017 07:48 |
|
eschaton posted:Er, you don’t think UIKit source code is included with Xcode and the iOS SDK, do you? I guess not. I'm just wondering how that works. Anyway never mind, no one has to explain. I can just look up how frameworks really work and maybe make one myself for the learning experience. LP0 ON FIRE fucked around with this message at 18:00 on Oct 27, 2017 |
# ? Oct 27, 2017 17:37 |
|
Now the camera output is suddenly not working and I didn't make any changes. Tried cleaning, deleting the app. Making me lose all faith in using Swift. What a waste of time.
|
# ? Oct 27, 2017 20:13 |
|
eschaton posted:Er, you don’t think UIKit source code is included with Xcode and the iOS SDK, do you? Christ, should we be so lucky
|
# ? Oct 27, 2017 20:15 |
|
Okay so the built in Camera app didn't even work on my phone! Just a black screen when I went to the camera. Restarted my phone. My app works. Welp, that was 3 hours well spent!
LP0 ON FIRE fucked around with this message at 20:44 on Oct 27, 2017 |
# ? Oct 27, 2017 20:21 |
|
Programming is just like that sometimes. poo poo don’t work and you dunno why.
|
# ? Oct 27, 2017 20:22 |
|
fleshweasel posted:Programming is just like that sometimes. poo poo don’t work and you dunno why. I nominate this post for understatement of the year.
|
# ? Oct 27, 2017 20:38 |
|
Speaking of... By far my biggest reported crash is OpenGL rendering in the background. GLEngine glFinish_Exec crashes on [GLKView display]. 1. Does anyone know of a (fairly) reliable way to recreate this? I can't figure out the series of app entering / exiting that gets this to occur. 2. I only start my displayLink in two places: from the UIApplicationDidBecomeActive notification and the view controller's viewDidAppear. The start function performs a check in each case: code:
|
# ? Oct 31, 2017 18:46 |
|
Oh, and I'm stopping the displayLink on all the following notifications: UIApplicationWillResignActiveNotification UIApplicationWillTerminateNotification UIApplicationDidEnterBackgroundNotification ...and on the view controller's viewWillDisappear.
|
# ? Oct 31, 2017 18:49 |
|
Running into an odd xcodebuild error when trying to build an iphone app from the command line:code:
|
# ? Oct 31, 2017 20:24 |
|
Not having the code signing certs installed on your new machine will produce that error.
|
# ? Oct 31, 2017 20:27 |
|
1) I'm trying to find out more about file storage and retrieval on iPhone. Is it correct to assume the string after Application in file:///var/mobile/Containers/Data/Application/[big random looking string here]/Documents/ is supposed to be secret for security reasons? 2) I'm trying to make a video out of a chain of images, and I found a Swift class for that: https://stackoverflow.com/a/41159403 Their example shows how to use fileURL in a player, and not how to save it to your phone, so I tried this, but I receive an error "Fetch failed: The operation couldn’t be completed. (Cocoa error -1.)" code:
|
# ? Nov 1, 2017 22:20 |
|
You need to store relative URLs rather than absolute because the iOS sandboxing allows it to move stuff around as it sees fit. You'll want to do something more along these lines:code:
|
# ? Nov 2, 2017 00:06 |
|
Stringent posted:You need to store relative URLs rather than absolute because the iOS sandboxing allows it to move stuff around as it sees fit. You'll want to do something more along these lines: Update I think I was just calling the wrong function all along. Now it claims it was saved, but I don't see it in my camera roll. Instead of using PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: fileURL) I use UISaveVideoAtPathToSavedPhotosAlbum(fileURL.path, nil, nil, nil) Older Thanks I'm still stumped, but I will do more research. Your code still looks like it creates an absolute path. code:
LP0 ON FIRE fucked around with this message at 20:30 on Nov 2, 2017 |
# ? Nov 2, 2017 20:19 |
|
It does create an absolute path, the trick is that [hash string] portion is subject to change by the operating system. So that's why you use the enums when calling url to get the pre:file:///var/mobile/Containers/Data/Application/[hash string]/Documents/ pre:exportvideo.mp4
|
# ? Nov 3, 2017 01:10 |
|
So I finally figured out that nothing was really wrong with the way I was trying to make the video from still images, except that the video was waaaay too large, giving me the vague "-1" error upon saving. Interestingly enough, it was able to say it was assembling the video and that it did exist. The only way I was able to get it to crash was to apply my video effect to each frame which was also vague - it just gave me a "Lost connection" to device error in Xcode!
LP0 ON FIRE fucked around with this message at 22:44 on Nov 7, 2017 |
# ? Nov 7, 2017 22:42 |
|
Plorkyeran posted:Not having the code signing certs installed on your new machine will produce that error. Thank you for the quick response! It was very helpful.
|
# ? Nov 8, 2017 20:50 |
|
Xcode is complaining about how I'm setting the camera flash is deprecated in iOS 10, but I have no idea how to set it now.code:
Which makes me think I"m supposed to set the flash mode like this: code:
Setting it with AVCapturePhotoSettings: code:
LP0 ON FIRE fucked around with this message at 23:20 on Nov 13, 2017 |
# ? Nov 13, 2017 22:35 |
|
How do people learn Accelerate? I'm trying to use it for linear algebra and signal processing, but I haven't seen any book for it, and the documentation is bare-bones. At the moment I'm digging through github and stackoverflow looking for sample code, but I don't know why it has to be this much of a pain.
|
# ? Nov 14, 2017 17:04 |
|
How come this is invalid:code:
but this is valid: code:
|
# ? Nov 15, 2017 06:17 |
|
I dunno, that's surprising. What Xcode are you using?
|
# ? Nov 15, 2017 07:46 |
|
rjmccall posted:I dunno, that's surprising. What Xcode are you using? 9.1 if I remember right. Next time I have the system in front of me I'll check the build number. e: reproduced on my other system, Xcode 9.1, build is 9B55. Maybe some context will help someone see what I'm doing wrong? It's just quicksort... code:
carry on then fucked around with this message at 15:17 on Nov 15, 2017 |
# ? Nov 15, 2017 15:07 |
|
|
# ? May 22, 2024 19:22 |
|
Wow the new code folding is garbage. Scrolling is molasses, and the entire text editor is filled up with buttons for expanding functions instead of the old {. . .} button. You can't position your cursor at the end of a function block anymore 😡 So pointless. And we still don't have a dark mode. edit: also lol at the function mouseover highlight bug. Just mouse over and scroll away and the button stays highlighted. Did an intern program this at the last second to 'wow' everyone in the office or something? lord funk fucked around with this message at 20:51 on Nov 15, 2017 |
# ? Nov 15, 2017 20:44 |