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
LP0 ON FIRE
Jan 25, 2006

beep boop
With lots of trial and error, I ended up making my own method to stroke text with some amazing results. I expected this to run slowly because it sometimes renders text with a stroke as a UIImage many times per second.


code:
-(void) renderTetraCount {
    
// I made my UIImageView in init. I can remove it here over and over.

    [textIMGView removeFromSuperview];
    
    UIImage *textIMG = [self outlineText:[NSString stringWithFormat:@"%d", tetraCount]];
    
    textIMGView = [[UIImageView alloc] initWithImage:(UIImage *)textIMG];
    CGRect headerFrame = textRect2;
    textIMGView.frame = headerFrame;
    [self addSubview:textIMGView]; 
    textIMGView.image = textIMG; 
    
    [textIMGView release];
    
}
code:
-(UIImage *)outlineText:(NSString *)text{
    
    UIFont *font = [UIFont fontWithName:@"Arial-BoldMT" size:22.0];  
    
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(txtWidth, txtHeight),NO,0.0);
    
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    //draw stoke first
    CGContextSetLineWidth(context, 4);
    CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0);
    CGContextSetTextDrawingMode(context, kCGTextStroke);
    CGContextSaveGState(context);
    [text drawAtPoint:CGPointMake(2,0) withFont:font];
    
    //then draw fill on top of stroke
    CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
    CGContextSetTextDrawingMode(context, kCGTextFill);
    CGContextSaveGState(context);
    [text drawAtPoint:CGPointMake(2,0) withFont:font];
    
    //send image
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();    
    
    return image;
}
It does not seem to impede on my game's performance whatsoever, even with large fonts. Other than that, feel free to mention if you see anything weird with my code.

Adbot
ADBOT LOVES YOU

Doc Block
Apr 15, 2003
Fun Shoe
You don't need to completely destroy & recreate the UIImageView every frame. Just do
code:
- (void)renderTetraCount
{
	UIImage *textIMG = [self outlineText:[NSString stringWithFormat:@"%d", tetraCount]];
	CGRect headerFrame = textRect2;
	textIMGView.frame = headerFrame;
	textIMGView.image = textIMG;
}
Also, it would probably be best if you could skip having to recreate textIMG every frame too. Only recreate it when tetraCount changes. Maybe write a setter for tetraCount that does something like
code:
- (void)setTetraCount:(int)count
{
	if(count != tetraCount) {
		tetraCount = count;

		UIImage *textIMG = [self outlineText:[NSString stringWithFormat:@"%d", tetraCount]];
		textIMGView.frame = textRect2;
		textIMGView.image = textIMG;
	}
}
Then you wouldn't even need your renderTetraCount method, so long as you only set tetraCount via its setter.

Doc Block fucked around with this message at 01:13 on Feb 10, 2012

LP0 ON FIRE
Jan 25, 2006

beep boop
Thanks Doc Block. I didn't realize I could just keep using that same UIImageView. I'll try that out tomorrow. Also it does only create a new image only if tetraCount changes, and not every frame.

wwb
Aug 17, 2004

Got a contractor who put their domain into the package name. App is pretty simple -- can I just change the package name in xcode and be done with it? Or are there other places I need to clean this up.

Funso Banjo
Dec 22, 2003

So, Apple have told us that we need to now include retina display screen shots for our iphone and ipod touch apps.

Now, avoiding the discussion of "Are you retarded, test your crap on a retina capable device you dweeb!" because my apps are making enough money without being developed for retina displays, I would like to ask if anyone knows of a way to get the simulator to provide retina resolution screen shots.

Anyone know? It might well be built in there. I have used simulator screen shots for all of my apps in the past, and all has been fine, just not certain whether the simulator has retina resolution (I imagine not).

Doc Block
Apr 15, 2003
Fun Shoe
In the simulator's menu, go Hardware->Device->iPhone (Retina)

Also, for non-game apps you don't have to do anything for Retina support beyond providing @2x images.

Your users will thank you if you do. I would hate using an app that, 1.5 years after the iPhone 4 came out, still doesn't use Retina images.

ManicJason
Oct 27, 2003

He doesn't really stop the puck, but he scares the hell out of the other team.
All right, fine, I'll update my four year old game for retina :mad:

lord funk
Feb 16, 2004

Graphics question: I am not using VBOs in my OpenGL pipeline. Will re-writing my graphics to use VBOs/VBAs improve the performance on the iPad 1? If this is to prevent sending geometric data to the graphics memory every frame, does this actually matter since the iPad 1 uses system memory?

Here's an Instruments run with the OpenGL Analyzer:

Doc Block
Apr 15, 2003
Fun Shoe
If it's a 3D game, you'll probably see a performance gain by switching to indexed arrays. Basically, you have an array of your vertexes, but not (necessarily) in the order to draw them. Then you have an array of 8- or 16-bit ints that are just indexes into your vertex array, and those are in draw order.

The idea is to cut down on the amount of data that needs to be sent to the GPU by not having to send over shared vertexes multiple times (once for each poly).

Not so sure about VBOs, though. Like you said, the iPad GPU uses shared memory. Maybe do a test app and see.

edit: in any case, it looks like you've got some optimizing to do.

Doc Block fucked around with this message at 02:03 on Feb 15, 2012

dorkfort.com
Sep 30, 2003

just another dork
Question for any iOS devs making (or planning to make) money through in-app purchases: what services/libraries/whatever do you use to record what people are actually doing in your app? (not counting Flurry, which really just tracks high level stuff)

Kallikrates
Jul 7, 2002
Pro Lurker
How are you guys unregistering observers and bindings in ARC projects? (since dealloc can't be counted on)

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Sorry, why can't -dealloc be counted on?

Kallikrates
Jul 7, 2002
Pro Lurker
I have many objects observing other objects, objects can be deallocated while there are still listeners attached.

The solution proposed here is to have them also listen to an 'alive' var and remove themselves when that value changes.
http://stackoverflow.com/questions/990069/when-should-i-remove-observers-error-about-deallocating-objects-before-removing

I'm just researching all options.

When dealloc is called, we can't trust that the object isn't being observed.

Kallikrates fucked around with this message at 20:12 on Feb 15, 2012

Zhentar
Sep 28, 2003

Brilliant Master Genius
That issue has nothing to do with whether or not you are using ARC.

Edit: Also, adding an observer does not increase the retain count. But if you're observing something, you should probably have a strong reference to it anyway.

Zhentar fucked around with this message at 20:08 on Feb 15, 2012

Kallikrates
Jul 7, 2002
Pro Lurker
We didn't start noticing it till after we switched the project over. But the affected bindings and observers are ones setup in IB.

lord funk
Feb 16, 2004

Doc Block posted:

If it's a 3D game ...

I just spent some time trying out some indexed drawing (got it to work... yay), when I realized that I'm drawing 2D only, so there aren't any duplicated vertices. :( I don't think I'll get a performance boost if I switch over.

Kallikrates
Jul 7, 2002
Pro Lurker
Ended up being a strong, weak ref issue.

duck monster
Dec 15, 2004

This has me mystified:
code:
-(void)retrieveTimeSheet {
    NSString *serverUrl=@"http://someshit/?date=2012-02-15";
    NSData *serverData=
            [NSData dataWithContentsOfURL:[NSURL URLWithString:serverUrl]];
    NSError *theError = nil;
    NSArray *jobsArray =
    [[CJSONDeserializer deserializer] deserialize:serverData error:&theError];
    
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
    NSString *testString = [[[jobsArray objectAtIndex:0] objectForKey:@"fields"] objectForKey:@"start_time"];
    NSLog(@"String: %@", testString);
    NSLog(@"Error: %@", theError);
    NSLog(@"Result: %@", [df dateFromString:testString]);
    
}
makes
code:

e: Also can I make NSData datawithcontentsofurl cookie aware, so I can poo poo some authentication down its throat first?
Attaching to process 8873.
2012-02-16 18:24:28.532 adamant[8873:fb03] String: 2012-02-15 09:00:00
2012-02-16 18:24:28.533 adamant[8873:fb03] Error: (null)
2012-02-16 18:24:28.534 adamant[8873:fb03] Result: 2012-02-15 01:00:00 +0000
:confused:

Carthag Tuek
Oct 15, 2005

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



As far as I can tell, NSDate is unaware of timezones, that all takes place in NSDateFormatter, so that might be it. Maybe this helps: http://stackoverflow.com/questions/2534757/nsdate-datefromstring-how-to-parse-around-utc-gmt-and-user-locale

You'll probably need NSMutableURLRequest if you want cookies

duck monster
Dec 15, 2004

Carthag posted:

As far as I can tell, NSDate is unaware of timezones, that all takes place in NSDateFormatter, so that might be it. Maybe this helps: http://stackoverflow.com/questions/2534757/nsdate-datefromstring-how-to-parse-around-utc-gmt-and-user-locale

You'll probably need NSMutableURLRequest if you want cookies

Aaaaahhhhh of course. I'm +8GMT, it all makes sense.

So according to that I could add a category onto NSDate or whatever it is to add a [mydate nonRetardedDateAnswer] message that ensures +8 is being adhered to.

Carthag Tuek
Oct 15, 2005

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



The NSDate docs say you shouldn't rely on -description (which is what is called when you log it like that) anyway, and use NSDateFormatters whenever you want to show a date to the user.

And actually I think NSDateFormatter by default uses your locale & timezone if you don't set anything, so I'm betting if you write out the date with a minimally configured formatter (basically just setting the format), it will display exactly as you need.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

When I create a simple Cocoa Application project, Xcode makes an 'AppDelegate.h/.m' and I put all the example code from a book in that code.

I have an older book (Cocoa Programming with Mac OS X, focusing on 10.2?) and in that version of Xcode you must have had to make the delegate classes by hand or something. Anyway, is there a way I can connect outlets to SomeOtherClass.m? Do I have to let my program know I want to access methods in those other classes, so I can get the 'blue cube' for that class to appear so I can connect Outlets to my nib?

I have newer books I just was curious to the answer to this question. I like this book (and am waiting for the new edition to come out), most of the stuff is still useful, it's just the initial setup and wiring up of the apps that gets weird.

Carthag Tuek
Oct 15, 2005

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



I'm not sure exactly what you mean.

If you want to add one of your own custom objects to a nib, find the blue cube/'Object' in the object library, add it to your nib, and change the class in the identity inspector.

If you want a class to be able to bind to other objects, you should add IBOutlets in the .h file.

If you want to connect some object to the app delegate, there's a delegate outlet in the Application object in the nib file under Placeholders.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice
Question about filtering an array on multiple criteria / parameters. Say I have an array of objects (returned form a Core Data fetch request, if that matters) with the properties name, color, hatSize and I am displaying them in a UITableView to the user.

If I let the user filter by color, that's simple: poop out a filtered array:

code:
NSPredicate *p = [NSPredicate predicateWithFormat:@"color == %@", userColor];
self.tableDataArray = [allItems filteredArrayWithPredicate:p];
...
Now if I want to add in filtering by hatSize as well, I have to keep track of if I filtered by color already to see if I need to only filter on allItems or on the previously filtered result. If I then add in filtering by name as well, I have to keep track of if I filtered by either of the other two and so on.

I'm sure this is a problem / pattern that's been done a billion times but I can't :google: the right terms, and I'm too dumb to see what will be the very obvious solution when someone takes pity on me and points it out.

dizzywhip
Dec 23, 2005

Lumpy posted:

Question about filtering an array on multiple criteria / parameters.

How about keeping an array of predicates and adding/removing them as the user adds or removes filters? Then just apply all of the predicates to generate your filtered array. It would probably be more efficient to store a list of conditions and create a single predicate that includes all of them, actually.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Gordon Cole posted:

How about keeping an array of predicates and adding/removing them as the user adds or removes filters? Then just apply all of the predicates to generate your filtered array. It would probably be more efficient to store a list of conditions and create a single predicate that includes all of them, actually.

Thanks. I don't know how I missed NSCompoundPredicate while reading up on this, but your post made the light-bulb go on.

Modern Pragmatist
Aug 20, 2008
I figure this may be the best place for this, as the Software thread is inundated with Mountain Lion talk for now and this seems more like a development-type question.

I'm attempting to run some software (mlint utility of Matlab, if it matters), and it's generating the following error when I run it from the command line
pre:
mp@helios:~$ mlint
dyld: Library not loaded: libtbb.dylib
  Referenced from: /Applications/MATLAB_R2011a.app/bin/maci64/libut.dylib
  Reason: image not found
Trace/BPT trap: 5
Ok, so I google around a bit, and find that you can use otool to figure out what dylib files it's looking for and where it thinks they are. So I run that on the libut.dylib file:

pre:
mp@helios:~$ otool -L /Applications/MATLAB_R2011a.app/bin/maci64/libut.dylib 
/Applications/MATLAB_R2011a.app/bin/maci64/libut.dylib:
        @loader_path/libut.dylib (compatibility version 0.0.0, current version 0.0.0)
        @loader_path/libmwi18n.dylib (compatibility version 0.0.0, current version 0.0.0)
        @loader_path/libmwfl.dylib (compatibility version 0.0.0, current version 0.0.0)
        @loader_path/libboost_date_time.dylib (compatibility version 0.0.0, current version 0.0.0)
        @loader_path/libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0)
        @loader_path/libboost_thread.dylib (compatibility version 0.0.0, current version 0.0.0)
        /usr/lib/libexpat.1.dylib (compatibility version 7.0.0, current version 7.2.0)
        @loader_path/libicudata.dylib.42 (compatibility version 42.0.0, current version 42.1.0)
        @loader_path/libicuuc.dylib.42 (compatibility version 42.0.0, current version 42.1.0)
        @loader_path/libicui18n.dylib.42 (compatibility version 42.0.0, current version 42.1.0)
        @loader_path/libicuio.dylib.42 (compatibility version 42.0.0, current version 42.1.0)
        libtbb.dylib (compatibility version 0.0.0, current version 0.0.0)
        libtbbmalloc.dylib (compatibility version 0.0.0, current version 0.0.0)
        /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 438.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 123.0.0)
So what I can guess from that is that it's basically looking in pwd to locate libtbb.dylib right? And I'm assuming I would have a similar problem with libtbbmalloc.dylib. This is further confirmed when I run the mint application from within the folder that it's stored in.

So, I guess there are two possible options:
1) Is it possible / worth it to edit the original dylib file to use @loader_path/libtbb.dylib instead? (I think this would fix it)
2) Is there some system variable I can set so to the parent folder so it will automatically find this dylib if the absolute path is not specified?

Carthag Tuek
Oct 15, 2005

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



Maybe look into the LD_LIBRARY_PATH environment variable or one of its ilk.

Modern Pragmatist
Aug 20, 2008

Carthag posted:

Maybe look into the LD_LIBRARY_PATH environment variable or one of its ilk.

Ah. It was DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH, thanks.

Modern Pragmatist fucked around with this message at 21:20 on Feb 17, 2012

The Born Approx.
Oct 30, 2011
Don't know if this is the right place for this but does anyone use gfortran on their Mac? I had it installed and working previously but I haven't used it in about a year. Today I was trying to compile something and I get this error:

gfortran: error trying to exec 'as': execvp: No such file or directory

I've done some googling and the only suggestions I can really understand are to download the latest version of XCode as well as install the latest version of gfortran for Lion which I've done. Still get the same error. I'm not a computer scientist so I don't understand what this is trying to tell me. Anyone have any idea?

xelfer
Nov 27, 2007

What's new, Buseycat? woa-aah, woa-aah, woa-aah

The Born Approx. posted:

Don't know if this is the right place for this but does anyone use gfortran on their Mac? I had it installed and working previously but I haven't used it in about a year. Today I was trying to compile something and I get this error:

gfortran: error trying to exec 'as': execvp: No such file or directory

I've done some googling and the only suggestions I can really understand are to download the latest version of XCode as well as install the latest version of gfortran for Lion which I've done. Still get the same error. I'm not a computer scientist so I don't understand what this is trying to tell me. Anyone have any idea?

http://www.macresearch.org/error_trying_to_exec_as_execvp_no_such_file_or_directory says it cant find gcc (or 'as').

does 'which gcc' or 'which as' give any results? eg:

code:
athena:~ nick$ which as
/usr/bin/as
athena:~ nick$ which gcc
/usr/bin/gcc
Open a terminal and type 'echo $SHELL' and it will tell you if you're using csh/tcsh/bash or sh then follow the instructions on adding the directories to your path.

Also have you installed XcodeTools.mpkg ? that seems to be suggested on that page as well.

The Born Approx.
Oct 30, 2011
Yeh gcc and as weren't installed in /usr/bin or /usr/local/bin for some reason, I had to go into XCode and download something called "Command Line Tools" for it to work, but it works now. Thanks!

duck monster
Dec 15, 2004

The Born Approx. posted:

Don't know if this is the right place for this but does anyone use gfortran on their Mac? I had it installed and working previously but I haven't used it in about a year. Today I was trying to compile something and I get this error:

gfortran: error trying to exec 'as': execvp: No such file or directory

I've done some googling and the only suggestions I can really understand are to download the latest version of XCode as well as install the latest version of gfortran for Lion which I've done. Still get the same error. I'm not a computer scientist so I don't understand what this is trying to tell me. Anyone have any idea?

as is the assemmbler gfortrans using in its compile toolchain, does gcc or any of that poo poo work?

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
Anyone run into crashes trying to use guard malloc? I am debugging an iOS 5 app on the latest Xcode in the simulator. If I try to turn on guard malloc, my app crashes immediately in __dyld_dyld_start (before main() even executes) with zero information. I've tried all sorts of research on this and I can't get the drat thing to work.

I'm targetting iOS 5 and am not weak-linking any libraries or doing anything else weird (that I can tell).

Edit: this is really weird as this is a new iOS 5 project on the iOS 5 simulator. I am using restkit, I wonder if that is causing a problem...

Edit2: Nope, brand new blank utility project template has the exact same problem. But running in the 4.3 simulator works just fine. There appears to be something broken in the 5.0 simulator environment. Also the actual crash point just says 0 <????> but the frames right before are _libxpc_initializer -> _xpc_domain_init_local -> mach_ports_lookup ->mig_get_reply_port -> <????>

Edit3: A lot of people who are getting this crash are weak-linking libSystem.B.dylib which apparently is no-good on the iOS 5 simulator. They changed to -weak-lSystem which apparently links the correct version of libSystem for the simulator vs the device. However libgmalloc.B.dylib references libSystem.B.dylib (according to otool) so perhaps Guard Malloc really is just horribly broken on the iOS 5 simulator.

Simulated fucked around with this message at 20:01 on Feb 19, 2012

Carthag Tuek
Oct 15, 2005

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



I don't have an answer except why aren't you using NSData?

lord funk
Feb 16, 2004

I'm using the new appearance features in iOS 5, and I can't figure this one out. I have a UISegmentedControl which I setUserInteractionEnabled:NO when a segment is chosen to prevent slowdown and accidental multi-taps. Now that I have custom images, though, this happens:

Normal view:


Then tap on a different segment (for example, Load / Save):


The default UISegmentedControl will have the Load / Save segment selected when it changes the alpha to indicate setUserInteractionEnabled:NO. Now, all of them grey out. It's a bit jarring.

Am I missing an image to set with UIBarMetrics? Setting the 'disabled' image just makes all of them the same.

lord funk
Feb 16, 2004

Nevermind. I just figured out I can set each segment individually. That works.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice
Core Data question: I read the guides but there are so many :words: my brain hurts, so I just want confirmation on something that I think is right.

Say I fetch a list of managed objects, show them to the user. User taps on a row and I move to a detail screen, passing a reference to the object anObject associated with the row they tapped. On this screen the user can edit some property; say name

They then press a button move to the next screen, again, passing a reference to anObject, and here the user could edit some other property if they wanted, but instead, they hit the 'cancel' button, which should un-do any changes to anObject and zip them back to the list.


Since I have not saved the context, no changes were made to the local store, so I should do:
code:
[myContext refreshObject:anObject mergeChanges:NO];


and then I can release my reference to anObject and all is well.

I cannot do
code:
[myContext deleteObject:anObject];


Because the list screen still is showing it, yes?

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
I just updated Xcode from the MAS and then it told me that I need to install the Command Line Tools because they're not installed by default. I don't have a developer account so I didn't install it, but I still have access to things like gcc, clang, make, and other Unix tools located in /usr/bin. What exactly am I missing here?

Adbot
ADBOT LOVES YOU

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Xcode no longer installs anything by default in /usr, but it won't blow things away that previous installs have put there. You don't need anything in /usr at all if you work exclusively within Xcode and its build system, but if you also want to be able to (e.g.) work on open-source Unix software with a Makefile-based build system, you should install the command-line tools. Contrariwise, if you never use Xcode and its build system, you can now just install the command-line tools without needing a full Xcode package.

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