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
rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Doctor w-rw-rw- posted:

I guess having varargs be char * is nice. I have an inkling on why that's important, but just to be sure - why?

The main thing is that all the variadic arguments are passed on the stack. This means that (1) the compiler has to know which arguments are variadic, which means user code has to call variadic functions using a correct function prototype, but also (2) it is much, much faster to process variadic arguments in the callee because you don't have to essentially undo the calling convention.

Adbot
ADBOT LOVES YOU

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

rjmccall posted:

The main thing is that all the variadic arguments are passed on the stack. This means that (1) the compiler has to know which arguments are variadic, which means user code has to call variadic functions using a correct function prototype, but also (2) it is much, much faster to process variadic arguments in the callee because you don't have to essentially undo the calling convention.

If they are on the stack, please tell me we can walk them and discover their types? (I know the answer is no, but I want it to be yes).

I think my hate of how varargs is designed now borders on the irrational.

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
A thing I learned yesterday: if you get an error code that makes sense neither in decimal (560557684) nor hexadecimal (0x21696E74), it's probably ASCII in disguise ("!int"). Put it in Calculator.app in programmer mode, and enable the "ASCII" toggle to see the hidden value. Now, the SDK headers that define ASCII error codes include both the decimal and hexadecimal equivalents in comments, so you can just grep for the number, but if you need a little peace of mind and a quick confirmation that the number isn't garbage, try this

e: oh wow, a cool feature of Calculator.app I didn't know about: if you click on a digit in the binary view, you can toggle that bit

hackbunny fucked around with this message at 10:22 on Mar 27, 2014

LP0 ON FIRE
Jan 25, 2006

beep boop
I just got a crash possibly from passing the incorrect integer value to a method. The thing that is strange is first off this just suddenly happened after changing nothing that I can recall, and I can see that the object is an NSNumber and the value inside is correct, but for some reason getting the intValue of that gives me something that looks like a memory address.

ThingKind is an enumerator.






Edit: I fixed it by switching around the order I add objects. The interactionIndex changed after another object was added, but still strange to me that the NSNumber says the correct number but charName is different.

LP0 ON FIRE fucked around with this message at 18:15 on Mar 27, 2014

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
Apple, you make me sad

quote:

dispatch_sync

[...] Calling this function and targeting the current queue results in deadlock.

[...]

As an optimization, this function invokes the block on the current thread when possible.

How can the two things be true at the same time? :confused: At least the deadlock is documented...? :sigh:

e: I guess there isn't a 1:1 correspondence between threads and queues

wakachamo
Dec 3, 2013

hackbunny posted:

e: I guess there isn't a 1:1 correspondence between threads and queues

Correct—that's the key thing about queues - only obvious exception being dispatch_get_main_queue(), I believe.

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
Except how can I tell if the argument is the same as the current queue, if dispatch_get_current_queue is deprecated? I just want to run code on the main thread synchronously, why does it have to be so hard

e: and we're back to old reliable -[NSObject performSelector:onThread:withObject:waitUntilDone:]

hackbunny fucked around with this message at 18:40 on Mar 27, 2014

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

hackbunny posted:

Except how can I tell if the argument is the same as the current queue, if dispatch_get_current_queue is deprecated?

What kind of case are you looking at here? Is there a reason you're trying to do this synchronously, potentially on the same queue, and not just running the code immediately?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

hackbunny posted:

Except how can I tell if the argument is the same as the current queue, if dispatch_get_current_queue is deprecated? I just want to run code on the main thread synchronously, why does it have to be so hard

Objective-C code:

if ([NSThread isMainThread]) {
    thinger();
} else {
    dispatch_sync(dispatch_get_main_queue(), thinger);
}

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
^^^ ugh of course, I'm an idiot

ultramiraculous posted:

What kind of case are you looking at here? Is there a reason you're trying to do this synchronously, potentially on the same queue, and not just running the code immediately?

Singleton initialized on arbitrary thread, I'm trying to wrap the call to -init in a dispatch_sync(dispatch_get_main_queue(), ...) to fix a race condition that's hard to pin down, but the more I think about it the less sense it makes

e: I remember now, the thread that initializes the singleton is going to become the official dispatcher of callbacks from ABAddressBookRegisterExternalChangeCallback for the rest of the lifetime of the process, so it had better be the main thread

hackbunny fucked around with this message at 18:54 on Mar 27, 2014

FlashBangBob
Jul 5, 2007

BLAM! Internet Found!
Pretty cool when your first App is in review to see the Apple tester/reviewer guy login. (At least I know login is working :ohdear:)

kitten smoothie
Dec 29, 2001

Alternately it's infuriating for it to sit in review for a week and then flip to ready for sale, yet your backend logs show they didn't even open the app once.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Ender.uNF posted:

If they are on the stack, please tell me we can walk them and discover their types? (I know the answer is no, but I want it to be yes).

Why would being on the stack affect that...?

If you want dynamically-discoverable types, you should almost certainly just use some C++11 variadic template trick.

Ender.uNF posted:

I think my hate of how varargs is designed now borders on the irrational.

The kind of type reflection that would enable the feature you're talking about is completely incompatible with the philosophy of C.

pokeyman posted:

Objective-C code:

if ([NSThread isMainThread]) {
    thinger();
} else {
    dispatch_sync(dispatch_get_main_queue(), thinger);
}

The real answer is "you should be much more conscious of what queue any particular bit of code is allowed to run on". Some utility code can make sense to execute on an arbitrary thread, sure. Event-management code that's actively jockeying tasks between queues? There is basically no sane design where you don't know what queue is responsible for running that. If you really need a few places to detect whether it's running on the main queue because some crappy API is subverting your queue design, then okay, but if you're pervasively writing code that doesn't know what queue it's on, then you probably either have massive races or you're writing really inefficient single-threaded code.

FlashBangBob
Jul 5, 2007

BLAM! Internet Found!

kitten smoothie posted:

Alternately it's infuriating for it to sit in review for a week and then flip to ready for sale, yet your backend logs show they didn't even open the app once.

Well thankfully they rejected it just after two days, and were really clear about what guideline I wasn't following. I was actually kind of thankful since there were two more bugs I found since uploading. Those bugs were minor and I was alright with releasing to the public, but are nice to now have fixed.

Doc Block
Apr 15, 2003
Fun Shoe
Apple App Review Team: helping developers get in those couple extra minor bug fixes before release since 2008.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

rjmccall posted:

The real answer is "you should be much more conscious of what queue any particular bit of code is allowed to run on". Some utility code can make sense to execute on an arbitrary thread, sure. Event-management code that's actively jockeying tasks between queues? There is basically no sane design where you don't know what queue is responsible for running that. If you really need a few places to detect whether it's running on the main queue because some crappy API is subverting your queue design, then okay, but if you're pervasively writing code that doesn't know what queue it's on, then you probably either have massive races or you're writing really inefficient single-threaded code.
Every single app I've worked on has needed if ([NSThread isMainThread) { ... } at some point (or a moral equivalent), and every time it's been due to a design fuckup. In general GCD seems to make threading easy enough that people can produce something that works, but not easy enough for something that's correct.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Plorkyeran posted:

Every single app I've worked on has needed if ([NSThread isMainThread) { ... } at some point (or a moral equivalent), and every time it's been due to a design fuckup. In general GCD seems to make threading easy enough that people can produce something that works, but not easy enough for something that's correct.

I would agree with that. GCD is a nice solution to some fairly narrow technical problems, but ultimately I think you need a language-level technology to really encourage a good design by locking down the thread-of-control interactions between subsystems — and I'm not sure how you could realistically impose that sort of thing retroactively, or that it would even produce a good environment given a clean slate. Competing approaches like Go's don't seem well-suited to GUIs, and things like FRP entail pretty radical changes to the language. It's a hard problem.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

We had an update take 3 months to get in, twice rejected after multiple weeks in-queue because of content served in a web view. Not "hey, fix that content somehow so that the partner's page doesn't link as directly to a non-Apple payment system, and we'll approve it", but right to the back of the line. Another time in that sequence was because of a server outage. This content changed daily anyway, and in major functional ways every week, and they knew it.

And then we found this gem on memegenerator, no doubt from an Apple review team person.

Good times.

ObContent: there used to be a library you could link that would let a target program turn on/off Shark profiling for itself. It was super helpful to expose to app script or similar to get clean profiles. I don't think that framework is around any more, but maybe someone knows of a way to do it? (At one point a co-worker was sending raw Mach messages and it worked, but that was a couple of years ago and er gross.)

Edit: fixed link; I swear I copied it from my browser!

Subjunctive fucked around with this message at 01:11 on Mar 28, 2014

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

rjmccall posted:

things like FRP entail pretty radical changes to the language.
IMO ReactiveCocoa works well enough to be worth using, but I suppose it does really want some features obj-c doesn't have (generics being the most obvious), and the implementation has to do some pretty awful things.

wakachamo
Dec 3, 2013

kitten smoothie posted:

Alternately it's infuriating for it to sit in review for a week and then flip to ready for sale, yet your backend logs show they didn't even open the app once.

IMO the App Review Team is one of this decade's biggest mysteries. I've had apps get opened for milliseconds and approved, others just incomprehensibly stared at for ours, others logged in once without doing a single thing, etc etc - I guess once you realise their original purpose is to make sure the app a) doesn't crash, b) looks the same as the screenshots you provide and seems to do what it does in the description and c) doesn't blatantly violate some specific guideline of your category, you also realise that they probably don't even have to go through the app at all most of the time.

With that said though I still really wanna know what really goes on in those offices which I can only assume are buried deep in rural North Korea or something.

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

rjmccall posted:

The real answer is "you should be much more conscious of what queue any particular bit of code is allowed to run on". Some utility code can make sense to execute on an arbitrary thread, sure. Event-management code that's actively jockeying tasks between queues? There is basically no sane design where you don't know what queue is responsible for running that. If you really need a few places to detect whether it's running on the main queue because some crappy API is subverting your queue design, then okay, but if you're pervasively writing code that doesn't know what queue it's on, then you probably either have massive races or you're writing really inefficient single-threaded code.

This app was written by outsourcers, educated idiots and uneducated idiots, with random contributions from whoever was free to plug the hole of the week. The sanest way to avoid synchronization issues is to run everything on the main thread, because there are no locks anywhere, and a lot of background threads. One of our core components is a C library that creates half a dozen background threads with the POSIX threads API, and its work queues are based on motherfucking select. Of course it calls back into Objective C code, which may or may not know about the absence of a dispatch queue or even an autorelease pool, depending on which of the six previous idiot savant/code janitor developers worked on a specific callback

Usually, dispatch_async is fine, but an initialization routine can't run asynchronously: you'd return before the initialization is done, with the object in an indefinite state, so dispatch_sync it is

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
Speaking of which, anyone knows of a way to diagnose deadlocks with pthreads locks? :cripes: I need to know what threads hold what locks and I'm drawing a blank. The lock structure is opaque and I can't find any debugger commands to inspect them

ptier
Jul 2, 2007

Back off man, I'm a scientist.
Pillbug

wakachamo posted:

IMO the App Review Team is one of this decade's biggest mysteries. I've had apps get opened for milliseconds and approved, others just incomprehensibly stared at for ours, others logged in once without doing a single thing, etc etc - I guess once you realise their original purpose is to make sure the app a) doesn't crash, b) looks the same as the screenshots you provide and seems to do what it does in the description and c) doesn't blatantly violate some specific guideline of your category, you also realise that they probably don't even have to go through the app at all most of the time.

With that said though I still really wanna know what really goes on in those offices which I can only assume are buried deep in rural North Korea or something.

It sounds a ton like patent examiners honestly. Some just reject to make a count, others scrutinize, some just gently caress around until its "time" for another. Sounds kinda soul-sucking. Imagine the amount of bullshit they have to deal with everyday with all the crappy bird / total clone / engrish day in, day out.

Doh004
Apr 22, 2007

Mmmmm Donuts...
Aside from keeping things more "organized", is there a reason to register your own defaults as opposed to just using standardUserDefaults to store some settings (in NSUserDefaults)? As long as I prefix all of my keys with my own App's naming scheme, I should be fine right?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Doh004 posted:

Aside from keeping things more "organized", is there a reason to register your own defaults as opposed to just using standardUserDefaults to store some settings (in NSUserDefaults)? As long as I prefix all of my keys with my own App's naming scheme, I should be fine right?

I don't understand your question. You are free to use NSUserDefaults as you see fit in your application, no prefix necessary. If you're writing a library, use a prefix to avoid collisions (see also: category method names). There is no reason to make your own settings system to circumvent NSUserDefaults.

haveblue
Aug 15, 2005



Toilet Rascal
The registerDefaults call is used to set the initial values of keys in NSUserDefaults, if you need them to not be zero/nil/empty for some reason. It's still using the same NSUserDefaults singleton and backing store.

Doh004
Apr 22, 2007

Mmmmm Donuts...
Ah okay, then yeah I got confused as to what that did.

I thought you could say add your own singleton, [NSUserDefaults myCustomDefaults]. But I don't really see the need for it as the standardUserDefaults is already specific to your app for that user.

Thanks for the clarification. Now on to enabling push notifications!

Peanut and the Gang
Aug 24, 2009

by exmarx
If I have a long title on a navigation bar, it cuts off the back button's text to only show the chevron. Is there a way to force iOS to clip more off the navigation bar and show the full text of the back button?

Doh004
Apr 22, 2007

Mmmmm Donuts...

Peanut and the Gang posted:

If I have a long title on a navigation bar, it cuts off the back button's text to only show the chevron. Is there a way to force iOS to clip more off the navigation bar and show the full text of the back button?

I don't believe so. Perhaps when you set the title, truncate it at a certain amount of characters?

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

hackbunny posted:

Speaking of which, anyone knows of a way to diagnose deadlocks with pthreads locks? :cripes: I need to know what threads hold what locks and I'm drawing a blank. The lock structure is opaque and I can't find any debugger commands to inspect them

I mean for pthreads there's nothing that "holds" a lock. It's just a counter. Log statements on mutex lock/unlocks can be pretty helpful here.

Also: Whyyyyyyyy :cripes:

Peanut and the Gang
Aug 24, 2009

by exmarx

Doh004 posted:

I don't believe so. Perhaps when you set the title, truncate it at a certain amount of characters?

Gotcha. I'll see how fruitful that direction is.

Doh004
Apr 22, 2007

Mmmmm Donuts...
*edit* Big rear end post about getting push notification development set up that worked itself out after turning airplane mode on and off for me, sorry about that.

Doh004 fucked around with this message at 01:08 on Mar 31, 2014

samiamwork
Dec 23, 2006

Peanut and the Gang posted:

If I have a long title on a navigation bar, it cuts off the back button's text to only show the chevron. Is there a way to force iOS to clip more off the navigation bar and show the full text of the back button?

Totally untested and not sure this is exactly what you want, but you might be able to do something like this:

code:
UILayoutPriority priority = [navbar.backbutton contentCompressionResistancePriorityForAxis:UILayoutConstraintAxisHorizontal];
priority--;
[navbar.titlelabel setContentCompressionResistancePriority:priority forAxis:UILayoutConstraintAxisHorizontal];

Peanut and the Gang
Aug 24, 2009

by exmarx

samiamwork posted:

Totally untested and not sure this is exactly what you want, but you might be able to do something like this:

code:
UILayoutPriority priority = [navbar.backbutton contentCompressionResistancePriorityForAxis:UILayoutConstraintAxisHorizontal];
priority--;
[navbar.titlelabel setContentCompressionResistancePriority:priority forAxis:UILayoutConstraintAxisHorizontal];

Sadly I think the back button doesn't extend from UIView in iOS 7. So something like that won't work out. :(

samiamwork
Dec 23, 2006

Peanut and the Gang posted:

Sadly I think the back button doesn't extend from UIView in iOS 7. So something like that won't work out. :(

I'm fairly sure it's descends from UIView (I can see all the subviews when I walk the navbar's view hierarchy) but it appears that it's not as easy to get to the actual button's view as I assumed. You'd probably have to do some things that Apple would frown on which ends up having the same sad outcome. =( Sorry for the distraction.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
WWDC tickets are by lottery this year: https://developer.apple.com/wwdc/tickets/

Given last year's debacle, it's the only reasonably fair way to do it. Go put your hat in the ring.

lord funk
Feb 16, 2004

Ender.uNF posted:

WWDC tickets are by lottery this year: https://developer.apple.com/wwdc/tickets/

Given last year's debacle, it's the only reasonably fair way to do it. Go put your hat in the ring.

Yeah this is fair. Entered, and good luck to everyone here!

Doh004
Apr 22, 2007

Mmmmm Donuts...
Much much better than last year. Hopefully we all get lucky :ohdear:

(we won't)

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
Is it possible to do iOS development on a windows or linux machine?

e: how lovely is it?

Newf fucked around with this message at 12:35 on Apr 4, 2014

Adbot
ADBOT LOVES YOU

kitten smoothie
Dec 29, 2001

Newf posted:

Is it possible to do iOS development on a windows or linux machine?

e: how lovely is it?

In theory you can run OS X in Virtualbox using some stuff that is shadier than the average Hackintosh setup so I'd call it :filez: and not discuss it in detail here.

In practice it will run so lovely that you'll try it and immediately go to the Apple Store and buy a cheap Mac mini out of anger and frustration.

I have no idea, for instance, if you'd be able to debug on a device through whatever USB bridging done by a VM.

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