|
fleshweasel posted:Can anyone help me understand how initializers work with inheritance in Swift and Objective-C? You can have convenience initializers that pass some default value to the designated initializer. Swift does not generate convenience initializers for you. When you instantiate an object, you can call any of the available initializers (convenience or designated). NSViewController probably has overridden -init as a convenience initializer that passes default values to the -initWithNibName:bundle: designated initializer. In your own initializers: - convenience initializers should call self.myDesignatedInitializer() with some default values instead of super.designatedInitializer(). - designated initializers should call super.designatedInitializer() According to this page (warning: article is from 2014), Apple's Swift iBook says: quote:A designated initializer must call a designated initializer from its immediate superclass. Doc Block fucked around with this message at 05:31 on Oct 15, 2016 |
# ? Oct 15, 2016 03:40 |
|
|
# ? Jun 5, 2024 19:08 |
|
carry on then posted:Awful is... awful for this. I'm sorry.
|
# ? Oct 15, 2016 04:23 |
|
Just quoting my question for this page:fleshweasel posted:Can anyone help me understand how initializers work with inheritance in Swift and Objective-C? I think I understand the concept of convenience and designated initializers, but am still confused by my situation. Like I said, I have an NSViewController subclass with no declared initializers. The only initializers that seem to be declared on NSViewController are failable (i.e. return type is NSViewController?), while the initializer exposed on my subclass is not failable. Which initializer on NSViewController is being called, and with what arguments?
|
# ? Oct 15, 2016 04:32 |
|
fleshweasel posted:Just quoting my question for this page: See my post at the top of the page. It's calling -init (NSViewController inherits from NSObject), which for NSViewController is probably overridden to be a convenience initializer that calls -initWithNibName:bundle: with some default values (probably either nil for both or the class name as the nib name). edit: -init probably passes nil for both parameters, since from macOS 10.10 and onward, passing nil as the nib name for -initWithNibName:bundle: will cause it to use the class name as the nib name, and thus will look for "MyClassName.nib" Doc Block fucked around with this message at 05:54 on Oct 15, 2016 |
# ? Oct 15, 2016 05:39 |
|
Does that mean the generated initializer on my subclass can call a convenience initializer of the superclass? A manually written initializer can't do that, though. (I have no idea why that restriction exists.) The designated initializer for NSViewController is also failable--so the convenience initializer must not only be calling the initializer that takes a bundle and nib name, but also applying the ! operator to it.
|
# ? Oct 15, 2016 06:50 |
|
There is no auto-generated initializer (at least not for Objective-C objects AFAIK). If you call -init on an Objective-C object that doesn't implement its own override of that method, the runtime just looks up through the class hierarchy until it finds a superclass that does, going all the way up to NSObject if needed (which does implement -init). Same as with any other method. NSViewController's convenience override of the -init method would be written in Objective-C. It could well be just as simple as Objective-C code:
Swift code:
Doc Block fucked around with this message at 08:35 on Oct 15, 2016 |
# ? Oct 15, 2016 08:17 |
|
pokeyman posted:I'm sorry. I should be thanking you for being the one to remind me where everything lives lol
|
# ? Oct 15, 2016 14:40 |
|
So I found and would like to use a little pod called CircleMenu, https://github.com/Ramotion/circle-menu, I added the pod and have got it to appear and do what it should. The problem is that as I don't understand what its actually doing I dont know how to add to it. I want the 5 buttons its produces to link to new views. I have segues setup and now how to call them but I don't have a clue where to add that code. Here is my viewcontroller code. code:
|
# ? Oct 17, 2016 07:04 |
|
Give your segues (different) identifiers in the storyboard editor, then depending on the button index call performSegue(withIdentifier:) with the appropriate identifier.
|
# ? Oct 17, 2016 12:45 |
|
pokeyman posted:Give your segues (different) identifiers in the storyboard editor, then depending on the button index call performSegue(withIdentifier:) with the appropriate identifier. Sorry I wasnt clear. I know how to perform the segue. What I dont know is where to put that code? Also I have no idea how to reference each button. I am guessing code:
|
# ? Oct 17, 2016 13:43 |
|
Do you want to perform one those segues when one of the buttons from the Circle menu is selected? If so, then yes, I'd imagine that's where you perform your segue.
|
# ? Oct 17, 2016 15:44 |
|
I cheated code:
thegasman2000 fucked around with this message at 17:00 on Oct 17, 2016 |
# ? Oct 17, 2016 16:24 |
|
I mean that's basically the implementation I had in my head when I gave my unhelpful reply, so if you cheated then I'm on team cheating!
|
# ? Oct 18, 2016 03:35 |
|
A few years ago I had an idea for a 2D game and coded up a quick prototype in Cocos2D (I forget what version, but whatever was current 2.5-3 years ago). Life left me with no time to do much more on it, but I am thinking of beginning again on it. Is Cocos2D still the go-to game thing these days? Switching to something else is no big deal, since I'll be basically re-learning iOS development at this point anyway.
|
# ? Oct 21, 2016 12:38 |
|
Cocos2D has had an... interesting history. The short version is that it's basically dead now. Some people are trying to keep the original Cocos2D (Objective-C version) alive, but AFAIK the main developers were forced to give up when the company that had been sponsoring them went bankrupt. The guys leading the project now have some... different goals than the previous developers. And then there's Cocos2D-X, which is Cocos2D but written in C++ (and it's an old version of Cocos2D, too, so layers are still a thing). It's being sponsored by a Chinese game developer, and some of the documentation is in pretty bad English. They brought over stuff like Objective-C's two stage initialization, which feels kinda weird in C++. And also pre-ARC Objective-C style reference counting, including autorelease. Cocos2D-X also has a weird, problematic Box2D physics integration. Many 2D games these days seem to use Unity3D's 2D sprite system, with all the pitfalls that entails.
|
# ? Oct 22, 2016 05:18 |
|
Use SpriteKit and target iOS, tvOS, and macOS too.
|
# ? Oct 23, 2016 01:36 |
|
Last time I tried SpriteKit it felt pretty limited. Some things were easy, but having it be a black box made other things more effort than it was worth. One day I might give it another look, because I don't care about Android support. Then again, my current game is using a custom 2D engine so I might just reuse that.
|
# ? Oct 23, 2016 19:10 |
|
SpriteKit has improved a lot. They added a companion framework GameplayKit for entity-component architectures and rules-driven AI. There's even a tilemap editor in Xcode.
|
# ? Oct 24, 2016 17:21 |
|
It's opaque physics engine doesn't do the things I need it to do, like planetary gravity and antigravity areas, but doesn't provide hooks for me to do them myself in a clean way like Chipmunk2D does. I would've had to write a function that runs after the physics engine and loops over every object, which seems like it would result in collision detection etc always being a frame behind. Seems like SpriteKit might've gotten better in terms of custom graphic effects now that you can do your own Core Image filters, but you still can't do custom drawing. And the last thing I would want is level creators monkeying around with the project in Xcode.
|
# ? Oct 24, 2016 17:52 |
|
Cool. I should go try it out. The last "game" I ever made was in Starling.
|
# ? Oct 24, 2016 17:56 |
|
Apple Documentation posted:Objective-C string constant is created at compile time and exists throughout your program’s execution. The compiler makes such object constants unique on a per-module basis, and they’re never deallocated. You can also send messages directly to a string constant as you do any other string
|
# ? Oct 25, 2016 17:47 |
|
Yes, it's done by both the compiler within a translation unit and the linker across translation units but within a linked image (dylib or executable). The linker may be blocked on certain strings, e.g. if they contain non-terminating nul characters.
|
# ? Oct 25, 2016 23:18 |
|
Thanks for the clarification!
|
# ? Oct 26, 2016 08:47 |
|
Thanks to all for the info on SpriteKit / Cocos2d. A question about this though:Doc Block posted:Many 2D games these days seem to use Unity3D's 2D sprite system, with all the pitfalls that entails. I was looking into Unity (I know nothing about it other than 'it exists') only because it seems under active development and might make ports to other platforms easier. Since I don't know what I don't know, what pitfalls are there in Unity / using it for 2D? My game has very simple gravity-based physics (object flies through space, might bounce off a thing or rebound "harder" off a rubber-band like wall) and not much else if that matters.
|
# ? Oct 26, 2016 14:32 |
|
Lumpy posted:Thanks to all for the info on SpriteKit / Cocos2d. A question about this though: Language feature set lies somewhere between .Net2 and .Net3.5, with some unity specific implementation bugs. Be prepared to pay for things that arguably should be included in the engine itself. If you run into a serious issue you're kind of SOL because you're probably not paying for source access. Other than that it's pretty easy, if opinionated, to work with.
|
# ? Oct 26, 2016 15:16 |
|
Lumpy posted:Thanks to all for the info on SpriteKit / Cocos2d. A question about this though: What leper khan said, plus a few other things:
Doc Block fucked around with this message at 20:02 on Oct 26, 2016 |
# ? Oct 26, 2016 20:00 |
|
Doc Block posted:[*]Your game logic gets written in an old version of C#, and C# doesn't compile to native code, and those two can be a performance bottleneck, especially on mobile. Unity has tried to work around this by creating their own .NET intermediary bytecode to C++ compiler (IL2CPP), which then hands that C++ code off to your C++ compiler. As you might imagine, this is not bug free. And, apparently, newer versions of Mono are much faster, incorporate LLVM, and reduce/eliminate the need for IL2CPP on non-mobile platforms. Microsoft had already open-sourced their compiler and the official runtime. Then Microsoft bought Xamarin and open-sourced everything. There is literally no reason for Unity to be using their half-assed IL2CPP hack.
|
# ? Oct 26, 2016 23:26 |
|
Simulated posted:Microsoft had already open-sourced their compiler and the official runtime. Then Microsoft bought Xamarin and open-sourced everything. There is literally no reason for Unity to be using their half-assed IL2CPP hack. They would have to spend the time to not use the things that are currently working. It isn't zero cost for them. Presumably they are doing this, as a modern .Net feature set is available in beta. I don't think they've specified their target for shipping it live.
|
# ? Oct 26, 2016 23:31 |
|
Thanks again for all the info! SpriteKit it is....
|
# ? Oct 27, 2016 12:30 |
|
Simulated posted:Microsoft had already open-sourced their compiler and the official runtime. Then Microsoft bought Xamarin and open-sourced everything. There is literally no reason for Unity to be using their half-assed IL2CPP hack. Well, there is the advantage of not having to ship the entire .NET runtime with each game, especially on mobile devices.
|
# ? Oct 27, 2016 19:26 |
|
Doc Block posted:Well, there is the advantage of not having to ship the entire .NET runtime with each game, especially on mobile devices. The Xamarin stack already has the ability to statically compile IL to assembly, that's. how they can ship on the iOS App Store.
|
# ? Oct 28, 2016 05:03 |
|
I have an issue with posting JSON giving a 400 error. Code looks like this... code:
code:
|
# ? Nov 11, 2016 22:02 |
|
thegasman2000 posted:I have an issue with posting JSON giving a 400 error. Code looks like this... It's much easier to diagnose web response errors if you log out the request & response both. That's my first goto when debugging a web thing. Am I really sending what I think I am, and is it to the right URL? Also (you might have tried it but just mentioning it for what it's worth): Double check the URL & try running the JSON you're posting through a linter (is there a hosed up character?).
|
# ? Nov 12, 2016 01:51 |
|
Also Content-Length should be number of bytes, not string length. (Probably not your main issue but I thought I'd mention it.)
|
# ? Nov 12, 2016 05:29 |
|
pokeyman posted:Also Content-Length should be number of bytes, not string length. (Probably not your main issue but I thought I'd mention it.) Hopefully that'll be a thing of the past with the swift server api thingie. Rid us of the boring stuff, please!
|
# ? Nov 12, 2016 05:57 |
|
Powaqoatse posted:
I have double checked the URL, its correct, but the issue is I have no idea how to print out the JSON to run it though a linter... I added a breakpoint and this is what I get. Looks good to me http://imgur.com/a/8XL4o Edit: my boss ran my project downloaded from git and it runs perfectly WTF? thegasman2000 fucked around with this message at 14:49 on Nov 13, 2016 |
# ? Nov 12, 2016 11:22 |
|
gently caress sake it was Xcode. Boss updates to 8.1 and I stayed in 8.0. That really should have been the case surely? Chasing my tail for 3 days because of that poo poo!
|
# ? Nov 14, 2016 13:57 |
|
How do people handle CoreData across multiple frameworks? I want just a shared main thread context and a background context for intensive writes/reads. I have this working for one big .xcdatamodel; however, we have a bunch of frameworks broken out due to business domains. When we've put entities into the big model that reference a class from another module, CoreData is unable to actually find the class when doing any fetches/insertions.
|
# ? Nov 14, 2016 18:34 |
|
You can specify the module in the model, make sure you're doing that correctly? Also I believe it's pretty easy to merge multiple models together at runtime. If it makes sense to divide your big model into per-module pieces that might work.
|
# ? Nov 14, 2016 23:50 |
|
|
# ? Jun 5, 2024 19:08 |
|
pokeyman posted:You can specify the module in the model, make sure you're doing that correctly? That's what we're doing, or at least attempting. I'm wondering if the framework that holds the .xcdatamodel MUST be linked with the frameworks that it references via its module? If so, we need to do some reorganizing in order to not introduce circular references (is that not a thing with Linked frameworks?)
|
# ? Nov 15, 2016 20:42 |