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
haveblue
Aug 15, 2005



Toilet Rascal
What's the behavior of GKAchievement if you set percentComplete to an out of bounds value? Does it ignore, clamp, blow up, or what? The documentation only says that it has a "range of legal values".

Adbot
ADBOT LOVES YOU

Bonefish
Jul 29, 2008
Is there a goon recommended book for the intermediate iPhone dev to get started in games? I loved the Big Nerd Ranch book and used it to make a real nice web content grabbing app, but it doesn't contain enough about games to make something full featured.

Doh004
Apr 22, 2007

Mmmmm Donuts...
I have a subclassed UIControl that I allow for me to set its own "callback" by passing in a selector and a delegate. This way I can reuse it and have it do whatever it needs to do once it's finished. That means I have the control doing:

code:
[passedInDelegate performSelector:passedInSelector]
XCode yells at me and says this could potentially cause a leak. Aside from just ignoring the warning, am I not supposed to do it this way? What's the correct way to go about this? I imagine I could pass in a block instead.

Froist
Jun 6, 2004

Doh004 posted:

I have a subclassed UIControl that I allow for me to set its own "callback" by passing in a selector and a delegate. This way I can reuse it and have it do whatever it needs to do once it's finished. That means I have the control doing:

code:
[passedInDelegate performSelector:passedInSelector]
XCode yells at me and says this could potentially cause a leak. Aside from just ignoring the warning, am I not supposed to do it this way? What's the correct way to go about this? I imagine I could pass in a block instead.

I hit exactly this problem this week in a pattern I was implementing (a reusable menu view). I just went with turning off the warning for that line in the end:

code:
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
    [self performSelector:item.action];
#pragma clang diagnostic pop

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Are you missing a push before ignoring the warning?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Doh004 posted:

I have a subclassed UIControl that I allow for me to set its own "callback" by passing in a selector and a delegate. This way I can reuse it and have it do whatever it needs to do once it's finished. That means I have the control doing:

code:

[passedInDelegate performSelector:passedInSelector]

XCode yells at me and says this could potentially cause a leak. Aside from just ignoring the warning, am I not supposed to do it this way? What's the correct way to go about this? I imagine I could pass in a block instead.

I've always imagined the idea here is to just use the UIControl target/action mechanism. If you need to, define your own control event (somewhere in the UIControlEventApplicationReserved bits). Then it works like any other control, multiple targets can register, etc. And as a side effect the compiler doesn't get antsy about ARC.

Another option is to define a protocol for your delegate.

But the least immediate effort is just to silence the warning locally. I'd take a look at the other options though, especially if this delegate does nothing but respond to your control's events.

Doh004
Apr 22, 2007

Mmmmm Donuts...

pokeyman posted:

I've always imagined the idea here is to just use the UIControl target/action mechanism. If you need to, define your own control event (somewhere in the UIControlEventApplicationReserved bits). Then it works like any other control, multiple targets can register, etc. And as a side effect the compiler doesn't get antsy about ARC.

Another option is to define a protocol for your delegate.

But the least immediate effort is just to silence the warning locally. I'd take a look at the other options though, especially if this delegate does nothing but respond to your control's events.

This is more of: control gets hit, it does whatever it needs to do (like present a uipopover), the user does whatever it does and taps something that then calls the selector on the given delegate.

Froist
Jun 6, 2004

pokeyman posted:

Are you missing a push before ignoring the warning?

... It appears I am. Thanks!

LP0 ON FIRE
Jan 25, 2006

beep boop
What is faster: Checking a bool or if an object is nil? I'm guessing the bool, but by a significant amount?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

LP0 ON FIRE posted:

What is faster: Checking a bool or if an object is nil? I'm guessing the bool, but by a significant amount?

If the value is completely opaque — loaded from memory or returned from a function — it is very likely that the performance will be completely equivalent. If it's not opaque, it's... actually still quite likely to be equivalent because it really doesn't take much compiler cleverness to treat the two cases equivalently. In fact, it should be equivalent in nearly every case imaginable — the only thing I can think of would be if the pointer was held in mis-aligned memory, or if you were storing the value permanently and didn't otherwise need to store the pointer and so ended up using extra storage because of it.

rjmccall fucked around with this message at 20:56 on Mar 28, 2013

Doctor w-rw-rw-
Jun 24, 2008

LP0 ON FIRE posted:

What is faster: Checking a bool or if an object is nil? I'm guessing the bool, but by a significant amount?

Since this is C, it's checking equality to zero either way. That's like, one instruction. Maybe two.

LP0 ON FIRE
Jan 25, 2006

beep boop
Good to know. In a game I've been doing checks every frame with bools and I wasn't sure if I'd be digging myself into a hole if I was checking for nil objects instead of having bools for them.

Doc Block
Apr 15, 2003
Fun Shoe
Remember, you aren't passing around objects in Objective-C, you're passing around object pointers. So, checking if an "object" is nil is really just checking if the pointer you have points to nil, which would be done with a simple integer comparison.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



You guys have some numbers on the amount of retains/releases from Intruments? Mine sit at about 10% for an app, and it seems quite high to me.

lord funk
Feb 16, 2004

Don't forget that the percent your seeing is the percentage of the percentage of your processor use. i.e., if you're only using 1% of your processor, even the tiniest cycle time seems huge.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



That's true, but they are the 2nd and 3rd obj-c methods in my app when looking at time spent.

I'm still learning Instruments so if that's normal I guess I'm just surprised.

E: Is there a way to see when/where they're called in Instruments? Maybe that could show me if I'm doing something stupid

Doc Block
Apr 15, 2003
Fun Shoe
Yeah, drill down far enough and it'll show you where in your code the calls are happening.

If it's even your code that's making all the retain/release calls.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Doc Block posted:

Yeah, drill down far enough and it'll show you where in your code the calls are happening.

If it's even your code that's making all the retain/release calls.

They just seem to end in objc::DenseMap stuff so it's not in my own code (using ARC if it matters).

Doc Block
Apr 15, 2003
Fun Shoe
Are you making a lot of objects in a tight loop? Or calling/doing something from a loop that could then be making a lot of temporary objects?

dizzywhip
Dec 23, 2005

Apparently getting a single sale was enough to make my app the #4 highest grossing app in the Honduras app store. I guess they don't sell much there?

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

Gordon Cole posted:

Apparently getting a single sale was enough to make my app the #4 highest grossing app in the Honduras app store. I guess they don't sell much there?

Belated congrats on the release.

dizzywhip
Dec 23, 2005

Thanks! It's off to a pretty slow start so far, but I think that's to be expected for a niche app like this.

NoDamage
Dec 2, 2000
There's a lot of backlash around iCloud + Core Data sync in the developer community right now. What I'm surprised by is how long it took, it's been almost two years since it was released, and basically no one has been able to ship a stable production app with it yet.

http://rms2.tumblr.com/post/46505165521/the-gathering-storm-our-travails-with-icloud-sync
http://arstechnica.com/apple/2013/03/frustrated-with-icloud-apples-developer-community-speaks-up-en-masse/
http://www.theverge.com/2013/3/26/4148628/why-doesnt-icloud-just-work

haveblue
Aug 15, 2005



Toilet Rascal
From reading those, a lot of the time was taken up by people being more forgiving of the 1.0 version that shipped in 10.7 and hoping that 10.8 would clean it up.

Glimm
Jul 27, 2005

Time is only gonna pass you by

NoDamage posted:

There's a lot of backlash around iCloud + Core Data sync in the developer community right now. What I'm surprised by is how long it took, it's been almost two years since it was released, and basically no one has been able to ship a stable production app with it yet.

http://rms2.tumblr.com/post/46505165521/the-gathering-storm-our-travails-with-icloud-sync
http://arstechnica.com/apple/2013/03/frustrated-with-icloud-apples-developer-community-speaks-up-en-masse/
http://www.theverge.com/2013/3/26/4148628/why-doesnt-icloud-just-work

NSHipster's post today was particularly great:
http://www.nshipster.com/icloud/

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I'm confused why the cavalcade of complaint starts now. Presumably iOS 7 is trucking along, and any relevant fixes, new API, etc. are being worked on. Informed, surely, by the bug reports and support issues everyone's submitting as they bang their heads against the wall. (If they're not filing bugs they should sit down.)

I'm not sure what the public airing of grievances is supposed to help. It's too small a story for a typical user to hear about it. If it's so nonfunctional then you'll find the problems pretty quick while developing against the Core Data iCloud APIs. I guess it's a bunch of cautionary tales for anyone starting a new app, or adding sync to an existing one?

edit: I can't think of any other recent developer revolts. Am I forgetting one?

Doc Block
Apr 15, 2003
Fun Shoe
Because the tech press loves an anti-Apple story.

lord funk
Feb 16, 2004

I've been holding out on iCloud in the hopes that it will include a friendly file-sharing capability. As in, browse files other users have uploaded and download them. It's probably a hail mary but I really don't want to implement that myself.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
At least now I know why a grand total of two apps I've ever installed have iCloud functionality.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

lord funk posted:

I've been holding out on iCloud in the hopes that it will include a friendly file-sharing capability. As in, browse files other users have uploaded and download them. It's probably a hail mary but I really don't want to implement that myself.

It's not too hard to do it yourself. Surprisingly cheap too. Pick up whatever language you like and write yourself a shiny server, then buy some cheap VPS on Linode or wherever and set it up.

You'll be done before iCloud is.

Doh004
Apr 22, 2007

Mmmmm Donuts...
I have a custom container view controller for my iPad app. It's like a reverse splitViewController, where the menu is on the right hand side and the content is on the left. The menu is just a viewController and a view that I place on the right hand side, while the contentView is where I transition whichever navigationController (button from the menu) the user is browsing.

I, for the life of me, cannot get the UINavigationController's navigationBar to only fit into the contentView's frame. Instead, the bar runs the full width of the app, causing the right rounded corner of the header to expand into the menu bar. My menubar is positioned above the contentView, so it just hides the "right side" of the navigation bar.

Any ideas as to what I can do to get this to work correctly? Googling has led me to believe in a UINavigationController will automatically fill up the full size of the screen. I would have assumed it would be of it's parent, so I think I'm being misled :(

kitten smoothie
Dec 29, 2001

This new framework from Heroku looks pretty impressive:

https://github.com/helios-framework/helios

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

pokeyman posted:

I'm confused why the cavalcade of complaint starts now. Presumably iOS 7 is trucking along, and any relevant fixes, new API, etc. are being worked on. Informed, surely, by the bug reports and support issues everyone's submitting as they bang their heads against the wall. (If they're not filing bugs they should sit down.)

I'm not sure what the public airing of grievances is supposed to help. It's too small a story for a typical user to hear about it. If it's so nonfunctional then you'll find the problems pretty quick while developing against the Core Data iCloud APIs. I guess it's a bunch of cautionary tales for anyone starting a new app, or adding sync to an existing one?

edit: I can't think of any other recent developer revolts. Am I forgetting one?

I guess some people didn't bother looking at the CoreData sync docs before they launched into a year-long update process, or they got massive user complaints in the field and tried to fix it over and over.

I took one look and knew it was bullshit; the design is fundamentally flawed and wouldn't work correctly even if it were 100% reliable. iCoud CoreData has no clue what objects are considered the "primary" parts of the object graph and which ones are subordinate relationships, so when it syncs it is just inevitable that it will muck up the relationships. Once the underlying store diverges, the transaction logs will never resolve properly and sync is permanently hosed.

Fixing it requires a complete redesign of the feature, preferably with someone who understands synchronization in a multi-master model. First issue is marking your primary entities so incompatible changes to a subordinate are discarded to preserve the primary. Deletes require a tombstone object so you can tie stuff back when the incoming log contains changes to it (or a child object that was also deleted). It also requires being able to represent two states of the object graph at the same time so your app can resolve conflicts intelligently, potentially pulling from either one. There are a whole bunch more - this poo poo is my bread and butter and it was obvious from day one that the design was broken.


Edit: this is aside from the issues when the user signs out of iCloud or the network is unavailable; even if those issues didn't exist it would still be a guaranteed way to give yourself a massive support headache as sync breaks when the user does the simplest things, like have the app open on their iPad and iPhone at the same time.


I've been thinking about doing my own iCloud CoreData sync by using the Ubiquity storage to pass files back and forth, not sure if/when I'll have time for it.

Simulated fucked around with this message at 22:10 on Apr 2, 2013

Toady
Jan 12, 2009

I notice NSPersistentDocument doesn't even support iCloud. I do hope they address all these issues.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Ender.uNF posted:

I've been thinking about doing my own iCloud CoreData sync by using the Ubiquity storage to pass files back and forth, not sure if/when I'll have time for it.

This stuff is decidedly not my bread and butter, but I'm surprised nobody's done this. (Maybe they have and aren't sharing.) And unlike Apple, you could require arbitrary constraints or extra metadata on the models in order to use the library.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Toady posted:

I notice NSPersistentDocument doesn't even support iCloud. I do hope they address all these issues.

As far as I know, the only Apple app that syncs Core Data over iCloud (Trailers, I think) works as well as anyone else's. The dog food's getting cold.

haveblue
Aug 15, 2005



Toilet Rascal
Is there a way to permanently eliminate the lag in initializing and using AVAudioPlayer? I'm playing out of a memory buffer, but the first time I use the class it takes about a third of a second to begin playing. Subsequent instances (a new instance per playback event) play back instantly (~20ms delay, which is good enough for me) but if I don't play an instance for a few seconds something gets released or evacuated and the next instance will incur the delay again.

Stack Overflow thinks I should give up on AVAudioPlayer and use OpenAL, but I figured I'd ask here first.

lord funk
Feb 16, 2004

It's probably hacky but could you play a silent audio file at init time to get passed the laggy start?

Inevitable Ross
Jul 1, 2007
Have you accepted Bob as your personal Lord and Savior?
Are you calling prepareToPlay on your player first? That supposedly buffers it.

Adbot
ADBOT LOVES YOU

haveblue
Aug 15, 2005



Toilet Rascal
I was calling prepareToPlay, but immediately before the play command (so just calling play had identical behavior). The funny thing is that the delay was both preventable and recurring. I was looking at the exact timing with log statements, and it would go something like this:

  • Application launch
  • Play request
  • 300ms processing
  • Sound plays
  • Very short interval (~1 second)
  • Play request
  • 20ms processing
  • Sound plays
  • Very short interval (~1 second)
  • Play request
  • 20ms processing
  • Sound plays
  • Long wait (~10 seconds)
  • Play request
  • 300ms processing
  • Sound plays

I'm guessing AVAudioPlayer requests some kind of temporarily sound-playing privilege and it gets expired or released after a period of inactivity. As before, the sound were all using the same NSData buffer so it wasn't due to having to hit the disk.

I ended up using OpenAL, which does not display this issue, but I'm still curious what the behind-the-scenes reason for this is.

haveblue fucked around with this message at 03:40 on Apr 3, 2013

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