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

Hughlander posted:

Anyone remember which WWDC 2012 talk was about C++11 features? Particularly lambdas/blocks? I want to pass an Obj C++ self inside a lambda to a C++ object that lives as a smart pointer in the obj C++ object, and want to make sure that it's not going to be maintaining strong references to each other because of it.

EDIT: Found it, it was What's new in LLVM (Session 410)

If you're using ARC, then yes, self will be strong. Therefore, if you capture it by value, then the corresponding field of the lambda will be strong. Therefore you'll get a retain cycle exactly like you would with a block.

But that cycle will be ephemeral unless the C++ object holds on to the lambda somehow (e.g. using a std::function).

Adbot
ADBOT LOVES YOU

Hughlander
May 11, 2005

rjmccall posted:

If you're using ARC, then yes, self will be strong. Therefore, if you capture it by value, then the corresponding field of the lambda will be strong. Therefore you'll get a retain cycle exactly like you would with a block.

But that cycle will be ephemeral unless the C++ object holds on to the lambda somehow (e.g. using a std::function).

Yes it would be held in a std::function, but no ARC. My use case was C++ class creates a pthread and a queue with a pthread conditional variable, calls std::function on success/fail of the operations. Obj C++ class creates the C++ class in an init method passing in a block of [self callbackSuccess]; Few other things going on using some crossplatform custom frameworks... In the end with the lifetime as it was listed I used lambda syntax in C++ and passed it as [=]{[self callbackSuccess];}

At somepoint I want to understand why when I tried
__block lambdaSelf = self; ^{[lambdaSelf callbackSuccess];} gave a bad access but that won't be today. (Unless the answer is that I didn't retain it / that only works under ARC?)

Doc Block
Apr 15, 2003
Fun Shoe
Yeah, it looks like self is being deallocated before the block is executed, leaving you with a dangling pointer in lambdaSelf. Which then gives you a bad access when you try to do [lambdaSelf callbackSuccess].

Doc Block fucked around with this message at 03:13 on May 16, 2013

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Hughlander posted:

Yes it would be held in a std::function, but no ARC. My use case was C++ class creates a pthread and a queue with a pthread conditional variable, calls std::function on success/fail of the operations. Obj C++ class creates the C++ class in an init method passing in a block of [self callbackSuccess]; Few other things going on using some crossplatform custom frameworks... In the end with the lifetime as it was listed I used lambda syntax in C++ and passed it as [=]{[self callbackSuccess];}

Lambdas and blocks have similar basic capture semantics: when you capture a variable by copy (which is what happens with blocks when you refer to a non-__block variable), the block/lambda ends up with a copy of the variable. And in general, that variable (the "capture field") has precisely the same semantics as the original variable and gets copy-initialized using the normal language rules.

However, there is a special case for non-ARC blocks: if the variable has an ObjC or block type, then when the block gets copied to the heap, the value in the capture field is retained (and released when the new heap block is deallocated). (This also happens by default in ARC, but it's not a special case: it falls out from the normal rules for copying __strong variables.)

But that special case is just for blocks; capturing a variable of ObjC or block type in a lambda does not insert magic retains. So no retain cycles for you.

Hughlander posted:

At somepoint I want to understand why when I tried
__block lambdaSelf = self; ^{[lambdaSelf callbackSuccess];} gave a bad access but that won't be today. (Unless the answer is that I didn't retain it / that only works under ARC?)

When you're not in ARC, variables are all unretained. When you capture a __block variable in a block, the block gets a strong reference to the variable, but that doesn't change the fact that the variable itself still holds its value as an unretained pointer. So yes, the problem is probably that the self object is getting deallocated because nothing is retaining it.

rjmccall fucked around with this message at 03:07 on May 16, 2013

lord funk
Feb 16, 2004

I have a UICollectionView zIndex issue. The UICollectionViewCells contain popover interface elements that can bleed out of the cell bounds. The zIndex of the cells gets completely mixed around by the way I'm arranging them (this is fine). But I need a way to make sure these interface elements appear on top of the cells. I figure there are two options:

1. Try and move the user interacted-with cell to the top. How can I do this without creating an entire UICollectionViewLayout?
2. Try and make the popover visuals a subview of some superview. This seems really iffy.

Any thoughts?

Only registered members can see post attachments!

Doc Block
Apr 15, 2003
Fun Shoe
For whatever view is bleeding, set its clipsToBounds property to YES, which will clip any parts of the view's sub views or custom drawing that fall outside the view's bounds. You could probably set it on the cell's contentView. There are performance implications, which is why the default is NO, but it sounds like you need it enabled.

edit: or are the contents supposed to bleed?

lord funk
Feb 16, 2004

Yes, they're supposed to bleed. The problem is that other cells that are higher up on the zIndex chain cover it up.

Doc Block
Apr 15, 2003
Fun Shoe
In the screenshots you posted, what is supposed to be happening? I'm assuming you want the Max Value field to be on top of the lines, right? In the screenshots, is the Max Value field what is extending beyond the bounds of the cell?

Sorry if I seem dense.

Doc Block fucked around with this message at 05:00 on May 20, 2013

lord funk
Feb 16, 2004

No worries - kind of weird to explain.

There is a guide view that appears when the user starts to drag my 'nub.' If the cell it's in is on top of all the other cells, it looks like this (this is what is supposed to happen):



If the cell is not on top, the guide view gets cropped at the bottom of the cell, which I don't want:

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 small question. The Data Formatting Guide states that:

quote:

For date and times in a fixed, unlocalized format, that are always guaranteed to use the same calendar, it may sometimes be easier and more efficient to use the standard C library functions strptime_l and strftime_l.

except that, as far as I can tell, strptime_l and strftime_l aren't actually available. Anything I'm missing?

haveblue
Aug 15, 2005



Toilet Rascal
Dumb question- did you #include <sys/time.h>? The POSIX API is not exposed to a stock project by default.

Doc Block
Apr 15, 2003
Fun Shoe

lord funk posted:

No worries - kind of weird to explain.

There is a guide view that appears when the user starts to drag my 'nub.' If the cell it's in is on top of all the other cells, it looks like this (this is what is supposed to happen):



If the cell is not on top, the guide view gets cropped at the bottom of the cell, which I don't want:



Ok. I'd probably just make a container view that holds the lines and whatnot then. That way you're guaranteed it'll be on top. Make it a sub view of the viewcontroller's view, hidden until needed.

lord funk
Feb 16, 2004

Doc Block posted:

Ok. I'd probably just make a container view that holds the lines and whatnot then. That way you're guaranteed it'll be on top. Make it a sub view of the viewcontroller's view, hidden until needed.

I'm thinking the same at this point. There's no way I'm rolling my own collection view layout just for that one issue. Plus, even if I can push cells to the top, if a user drags two at a time, there's a chance one will still cover up the other.

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

haveblue posted:

Dumb question- did you #include <sys/time.h>? The POSIX API is not exposed to a stock project by default.

<time.h> actually, <sys/time.h> is a little too low-level. The problem is that strftime_l (the variant of strftime where you can override the locale used without mucking with POSIX environment variables) is defined in the non-standard <xlocale/_time.h>, which is included in <time.h> if _USE_EXTENDED_LOCALES_ is defined. Now, _USE_EXTENDED_LOCALES_ is completely undocumented and I'm not sure whether I'm supposed to define it, or if it's defined by the build environment under certain conditions, or whatever

e: I ended up using NSDateFormatter anyway

Doh004
Apr 22, 2007

Mmmmm Donuts...
Crashlytics good, yes? Better than the "live" reporting from TestFlight?

Carthag Tuek
Oct 15, 2005

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



hackbunny posted:

<time.h> actually, <sys/time.h> is a little too low-level. The problem is that strftime_l (the variant of strftime where you can override the locale used without mucking with POSIX environment variables) is defined in the non-standard <xlocale/_time.h>, which is included in <time.h> if _USE_EXTENDED_LOCALES_ is defined. Now, _USE_EXTENDED_LOCALES_ is completely undocumented and I'm not sure whether I'm supposed to define it, or if it's defined by the build environment under certain conditions, or whatever

e: I ended up using NSDateFormatter anyway

I've done date stuff like this (needed because NSDateFormatter was too slow in my case):

Objective-C code:
#include <time.h>
#include <xlocale.h>

const char *formatString = "%e %b %Y %H:%M:%S %z";

static inline NSDate * dateFromString(NSString *dateString) {
    struct tm  timeResult;
    
    strptime_l([dateString cStringUsingEncoding:NSASCIIStringEncoding], formatString, &timeResult, NULL);
    
    NSDate *date = [NSDate dateWithTimeIntervalSince1970: mktime(&timeResult)];
    
    return date;
}
It's probably awful C because I'm mostly used to higher level stuff, but it works.

lord funk
Feb 16, 2004

Doc Block posted:

Ok. I'd probably just make a container view that holds the lines and whatnot then. That way you're guaranteed it'll be on top. Make it a sub view of the viewcontroller's view, hidden until needed.

Follow up: this worked really well. I pass a weak reference of the collection view controller's view to the cell view controller, which is the delegate of the nub UI elements. The nub handles adding / showing / hiding the view and can translate from local coordinates to the top VC coordinates. Works great!

lord funk
Feb 16, 2004

More fun with collection views. They're pretty cool, but the default layout rules are weird. Cells left justify, unless they are not in the final row, in which case they center justify... unless there are cells in previous rows, and the last row only has one cell. :what:

Quick justification demo:

edit: wait I think that's my fault
edit2: maybe not

Only registered members can see post attachments!

lord funk fucked around with this message at 23:27 on May 20, 2013

catbread.jpg
Feb 22, 2007
I'm using TheAmazingAudioEngine to capture audio input, with a receiver object implementing a C callback that is called as part of the real-time audio thread (to transfer buffer data).

I want to trigger a method off the completion of the callback, but as it is part of the audio thread it is not allowed to make any obj-c calls etc. I do have access to all the instance variables of the receiver object. The callback will run every 10 ms or so, so it needs to be pretty fast about it.

Doctor w-rw-rw-
Jun 24, 2008

catbread.jpg posted:

I'm using TheAmazingAudioEngine to capture audio input, with a receiver object implementing a C callback that is called as part of the real-time audio thread (to transfer buffer data).

I want to trigger a method off the completion of the callback, but as it is part of the audio thread it is not allowed to make any obj-c calls etc. I do have access to all the instance variables of the receiver object. The callback will run every 10 ms or so, so it needs to be pretty fast about it.

you can't use Grand Central Dispatch to run a method on the main queue?

Doc Block
Apr 15, 2003
Fun Shoe

lord funk posted:

More fun with collection views. They're pretty cool, but the default layout rules are weird. Cells left justify, unless they are not in the final row, in which case they center justify... unless there are cells in previous rows, and the last row only has one cell. :what:

Quick justification demo:

edit: wait I think that's my fault
edit2: maybe not



Weird. This is with flow layout?

duck pond
Sep 13, 2007

lord funk posted:

More fun with collection views. They're pretty cool, but the default layout rules are weird. Cells left justify, unless they are not in the final row, in which case they center justify... unless there are cells in previous rows, and the last row only has one cell. :what:

Quick justification demo:

edit: wait I think that's my fault
edit2: maybe not



Whoa. I'm just taking Bryan Hansen's UICollectionView tutorial (which btw everybody, is real good) and still only just starting to get a sense of what is possible with it.

duck pond fucked around with this message at 10:03 on May 21, 2013

duck pond
Sep 13, 2007

catbread.jpg posted:

I'm using TheAmazingAudioEngine to capture audio input, with a receiver object implementing a C callback that is called as part of the real-time audio thread (to transfer buffer data).

I want to trigger a method off the completion of the callback, but as it is part of the audio thread it is not allowed to make any obj-c calls etc. I do have access to all the instance variables of the receiver object. The callback will run every 10 ms or so, so it needs to be pretty fast about it.

Oh hey sup catbread. Yeah you wanna do what Doctor w-rw-rw- says basically, once you have the THIS object it should be as easy as

code:
dispatch_async(dispatch_get_main_queue(), ^{
    [THIS doAThing];
});
Edit: If you run into problems (if you're doing what I think you're doing (re-using that oscilloscope class that came with TAAE)) and this runs slow perhaps set something up so it only does this once every fourth loop or so? For now at least.

duck pond fucked around with this message at 10:24 on May 21, 2013

lord funk
Feb 16, 2004

Doc Block posted:

Weird. This is with flow layout?

Yes, and it is not okay for human consumption. I guess instead of 'flow' layout they should call it 'okay for image grids that don't change really' layout. I'm finding oddity after oddity.

duck pond posted:

Whoa. I'm just taking Bryan Hansen's UICollectionView tutorial (which btw everybody, is real good) and still only just starting to get a sense of what is possible with it.

Checking this out. It's time to make my own layout.

Doc Block
Apr 15, 2003
Fun Shoe
Making your own layouts isn't as hard as it sounds. NSScreenCast covered it in their UICollectionView episode.

Doc Block fucked around with this message at 23:26 on May 21, 2013

Glimm
Jul 27, 2005

Time is only gonna pass you by

Does anyone have experience using NUI (https://github.com/tombenner/nui) in an iOS application? It looks really neat, basically it allows for creating CSS like style sheets to quickly change the look of an application. Because I mostly use IB in development it's always such a pain for me when the shade of the predominant font in the app changes there is no single point to handle it, and NUI looks like it will make things like this far simpler.

But yeah, basically I'm wondering if using this is going to make styling things as simple as Android styles/themes, or are there headaches this is going to bring to the table I'm unaware of?

Doctor w-rw-rw-
Jun 24, 2008
It's just a layer over UIAppearance, so I suppose it shouldn't be too bad. At least, it should be good enough to try out IMO.

Glimm
Jul 27, 2005

Time is only gonna pass you by

Doctor w-rw-rw- posted:

It's just a layer over UIAppearance, so I suppose it shouldn't be too bad. At least, it should be good enough to try out IMO.

It seems a bit more useful than UIAppearance at least, UILabels for instance don't appear to be supported in UIAppearance but it looks like NUI handles them. UILabel support is what drove me away from just using UIAppearance.

edit:

Here's a kind of helpful list of what UIAppearance can handle: https://gist.github.com/mattt/5135521

Glimm fucked around with this message at 18:26 on May 22, 2013

Doh004
Apr 22, 2007

Mmmmm Donuts...
Due to customer privacy concerns, we now have to roll our own crash reporting logs and submit them to our own servers. I'm trying out Plcrashreporter but it's actually crashing when handling an uncaught exception. :what:

Anyone have experience making their own?

Hughlander
May 11, 2005

Doh004 posted:

Due to customer privacy concerns, we now have to roll our own crash reporting logs and submit them to our own servers. I'm trying out Plcrashreporter but it's actually crashing when handling an uncaught exception. :what:

Anyone have experience making their own?

What SHA of PlCrashReporter? We use 2.0 beta1, SHA: a24b93f01a87073ccd7113a8615a9304de47dbe5 and it's pretty drat Metal.

Doh004
Apr 22, 2007

Mmmmm Donuts...

Hughlander posted:

What SHA of PlCrashReporter? We use 2.0 beta1, SHA: a24b93f01a87073ccd7113a8615a9304de47dbe5 and it's pretty drat Metal.

There's a 2.0 out? I just downloaded the "Featured" one: 1.1 RC2: f31296756a572d544a206116d3adf33bd6cde654 http://code.google.com/p/plcrashreporter/downloads/detail?name=PLCrashReporter-1.1-rc2.dmg&can=2&q=

Perhaps I should try out 2.0.

I also had no idea what I was doing. I had to build the .a file from the source and I doubt I did that correctly. I tried to follow: http://stackoverflow.com/questions/6192897/plcrashreporter-in-xcode-4-wont-compile-in-simulator

lord funk
Feb 16, 2004

Is this just a popover with a UISegmentedControl, or is it a particular object I can't find on Google? I need coffee.

Only registered members can see post attachments!

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
It's UIMenuController.

Good luck.

lord funk
Feb 16, 2004

pokeyman posted:

It's UIMenuController.

Good luck.

Thanks. Also why is this so hard to make it appear.

lord funk fucked around with this message at 16:37 on May 23, 2013

Glimm
Jul 27, 2005

Time is only gonna pass you by

lord funk posted:

Thanks. Also why is this so hard to make it appear.

Not sure about this, but one thing to look out for when using UIMenuController is to be sure to use the sharedMenuController instance (http://developer.apple.com/library/...dMenuController). Bad things can happen otherwise!

lord funk
Feb 16, 2004

Glimm posted:

Not sure about this, but one thing to look out for when using UIMenuController is to be sure to use the sharedMenuController instance (http://developer.apple.com/library/...dMenuController). Bad things can happen otherwise!

Got that, but the class reference poorly documents the required responder calls. You have to override -(BOOL)canBecomeFirstResponder to return YES, you have to call [self becomeFirstResponder], and you have to implement -(BOOL)canPerformAction:withSender:. From the docs:

quote:

The canPerformAction:withSender: method of UIResponder is also related to the editing menu.

Okay, but just let me know it's required.

lord funk fucked around with this message at 16:44 on May 23, 2013

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

lord funk posted:

Thanks. Also why is this so hard to make it appear.

UIMenuController is depressingly hard to customize, and documentation is sparse (as you've already found). If you want to use it within a text view or table view, it might be worth using. Otherwise I'd just make my own control.

When I'm been stuck with it, I find PSMenuItem helpful; it turns the responder chain garbage into blocks. (I'm familiar with the responder chain in general and it's great, but UIMenuController shits the bed here.) And at some point I came across UIMenuItem (CXAImageSupport) but haven't had a chance to use it yet. That one lets you use images in the menu items, like the bold/italic/underline items in Mail.

Doh004
Apr 22, 2007

Mmmmm Donuts...

Doh004 posted:

There's a 2.0 out? I just downloaded the "Featured" one: 1.1 RC2: f31296756a572d544a206116d3adf33bd6cde654 http://code.google.com/p/plcrashreporter/downloads/detail?name=PLCrashReporter-1.1-rc2.dmg&can=2&q=

Perhaps I should try out 2.0.

I also had no idea what I was doing. I had to build the .a file from the source and I doubt I did that correctly. I tried to follow: http://stackoverflow.com/questions/6192897/plcrashreporter-in-xcode-4-wont-compile-in-simulator

It works! Turns out you can't run it in Simulator (something I probably should have guessed), but running it on devices actually works.

Now, to figure out how to get an actual stack trace out of all of this.

Doh004
Apr 22, 2007

Mmmmm Donuts...
Sorry for the double post but now we're stumped. PLCrashReporter is working fine when we build to a device, but in our CI (TeamCity) we get this error:

code:
 /applications/buildagent/work/7a3b9eca33cd6bf4/MyApp/AppDelegate.m:19:9: fatal error: 'CrashReporter/CrashReporter.h' file not found
#import <CrashReporter/CrashReporter.h> 
Which doesn't make sense at all as we know for a fact it's there. Everything builds fine on another developer's machine, and we've even run the same build. I even copied the same exact build command that TeamCity uses and ran it on my machine and it worked fine.

Am I missing something obvious here?

Adbot
ADBOT LOVES YOU

Inevitable Ross
Jul 1, 2007
Have you accepted Bob as your personal Lord and Savior?
Release vs debug mode? Missing copy/include in a build phase?

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