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
lord funk
Feb 16, 2004

Gordon Cole posted:

I guess the reason I don't run into issues is that I almost always design my classes with the mindset that the properties are only for external use.

I'm glad someone else does this. I've been seeing properties used for everything, and can't figure out why.

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Gordon Cole posted:

I guess the reason I don't run into issues is that I almost always design my classes with the mindset that the properties are only for external use. But obviously that doesn't work for every situation so I can see the two getting mixed up in some cases.

I used to do this too, but I've since decided on using accessors everywhere except in -init and -dealloc. Makes it harder to screw up your retain/release/(will/did)ChangeValueForKey and any other side effects of setting properties. Less repetition. I can't think of a downside to using the accessors everywhere.

And any properties not for external use I put in a class extension in my .m file. I rarely write a class with an explicit ivar anymore.

e: I should add that I don't think there's anything wrong with using the ivar directly. Ubiquitous properties has cut down on memory management bugs for me and decreases the number of lines of code I have to write. Even more so once default synthesis happens. (Why aren't properties synthesized by default, then you just use @dynamic to prevent it?)

pokeyman fucked around with this message at 00:56 on Mar 16, 2012

Zhentar
Sep 28, 2003

Brilliant Master Genius
I agree with pokeyman; my policy is to never set to an ivar. Gets I don't feel so strongly about, but I've never been in the situation where something would have been easier to change if a property had been an ivar, but the reverse isn't true, so my preference is to use accessors there as well.

klem_johansen
Jul 11, 2002

[be my e-friend]
I'm getting an odd issue where XCode says that a header file can't be found even though the file is right there in the project browser. I've even gone so far as to delete the file and bring it back in, but there's no difference. Oddly, the project will usually compile just fine but it's unreliable. Any ideas?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Delete the folder in ~/Library/Developer/Xcode/DerivedData that corresponds to your app?

LP0 ON FIRE
Jan 25, 2006

beep boop
I know this might sound sort of arbitrary, but I thought my Cocos2D game with the 3rd generation iPad would take advantage of it's faster processor and give me a higher fps. It was running really well on the iPad 2 so I thought it would be pegging at 60fps all the time, but it seems to running the same as it was before. Are there any extra build settings I should change?

lord funk
Feb 16, 2004

Time to post retina screenshots!



Post if you got em.

Doc Block
Apr 15, 2003
Fun Shoe

LP0 ON FIRE posted:

I know this might sound sort of arbitrary, but I thought my Cocos2D game with the 3rd generation iPad would take advantage of it's faster processor and give me a higher fps. It was running really well on the iPad 2 so I thought it would be pegging at 60fps all the time, but it seems to running the same as it was before. Are there any extra build settings I should change?

It depends on what your game is doing, and how well optimized it is. If you have lots of overdraw then you're going to be fillrate limited, and with 4 times as many pixels to draw, things aren't going to be magically fixed.

The main goal with the iPad 3's GPU and CPU seems to have been to keep things at roughly the same framerate but at 4 times the resolution. Throwing 2 more cores into the GPU is a brute-force solution to improving GPU performance, and (I would think) mainly benefits fillrate.

Also, Cocos2D has some optimization issues, according to Instruments' OpenGL ES analyzer.

edit: it also depends on how recent your Cocos2D build is. The 1.1 and 2.0 betas get better performance, and don't have touch issues when using the DisplayLink director.

edit 2:


I wish the artist who did the doodles had done a cleaner scan or whatever. The rough edges are more noticeable than I thought they would be. Gonna see if they can be cleaned up.

Doc Block fucked around with this message at 21:40 on Mar 16, 2012

LP0 ON FIRE
Jan 25, 2006

beep boop

Doc Block posted:

It depends on what your game is doing, and how well optimized it is. If you have lots of overdraw then you're going to be fillrate limited, and with 4 times as many pixels to draw, things aren't going to be magically fixed.

The main goal with the iPad 3's GPU and CPU seems to have been to keep things at roughly the same framerate but at 4 times the resolution. Throwing 2 more cores into the GPU is a brute-force solution to improving GPU performance, and (I would think) mainly benefits fillrate.

Also, Cocos2D has some optimization issues, according to Instruments' OpenGL ES analyzer.

edit: it also depends on how recent your Cocos2D build is. The 1.1 and 2.0 betas get better performance, and don't have touch issues when using the DisplayLink director.

Hmm.. I think I understand. So by theory if my code is optimized and I'm not doing anything overzealous, my game should run about the same with retina graphics. I've been running v0.99.5, and I don't feel so comfortable upgrading since I've edited the framework so much. :geno:

lord funk
Feb 16, 2004

In case anyone else encounters this with retina upgrades:



That dark blue line under the keyboard button isn't actually part of the image. It's not in the background - it just appears there. Other UIImageViews have the same issue with other colors around the edges.

The solution I found: the line only appears in PNG-8 images. If you save as PNG-24, the line goes away. Just FYI.

Doc Block
Apr 15, 2003
Fun Shoe
If it works for your current game then stay with it. But I'd use 1.1 or 2.0 for any new games. They have better performance and a lot of cool things that weren't in earlier releases.

lord funk posted:

In case anyone else encounters this with retina upgrades:



That dark blue line under the keyboard button isn't actually part of the image. It's not in the background - it just appears there. Other UIImageViews have the same issue with other colors around the edges.

The solution I found: the line only appears in PNG-8 images. If you save as PNG-24, the line goes away. Just FYI.

Good to know.

I don't think you save anything other than disk space with PNG-8 images on iOS anyway. The GPUs don't support color-indexed images (as far as I know), so once a PNG-8 is loaded iOS would have to convert it into something non-indexed like RGB565 or RGB8.

Doc Block fucked around with this message at 22:15 on Mar 16, 2012

Carthag Tuek
Oct 15, 2005

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



Doc Block posted:

edit 2:


I wish the artist who did the doodles had done a cleaner scan or whatever. The rough edges are more noticeable than I thought they would be. Gonna see if they can be cleaned up.

Even if you don't have originals to rescan, the drawings are clean enough as they are that you should be able to vectorize them and then just rasterize to desired resolution.

(Resolutionary!)

lord funk
Feb 16, 2004

Doc Block posted:

I don't think you save anything other than disk space with PNG-8 images on iOS anyway. The GPUs don't support color-indexed images (as far as I know), so once a PNG-8 is loaded iOS would have to convert it into something non-indexed like RGB565 or RGB8.

I figured it had something to do with indexed color. And I do only use PNG-8 for saving disk space - 95% of the app size is the images. When I was finishing my first app, I went to upload it and it was something like 30MB. I hadn't compressed any images. After going through them all, the app was like 5MB.

Small White Dragon
Nov 23, 2007

No relation.
I'm developing a command line OS X utility in Xcode.

Is there a way to get Xcode to put resources with the resultant binary for testing purposes?

When I run it in 4.3.1, sometimes the debugger window at the bottom vanishes as soon as the utility has finished running -- which is annoying, since I wanted to see its output. Any idea how I can get fix this?

Carthag Tuek
Oct 15, 2005

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



There's a build phase called "copy files" where you can put what you want copied where when building.

The second point can be configured under the menu XCode > Behaviours > Edit Behaviours... For instance, the default for "Testing succeeds" isn't set up to show anything, so it hides the debugger + log. Mine's set to [Show] debugger with [Current Views].

duck monster
Dec 15, 2004

PT6A posted:

Right-click the screenshot in the organizer and select "show in finder". Then get info. That's the only way I can ever manage to find the miserable loving things.

They are not appearing in the organizer.

Also user setup is;- just one user, me.

duck monster
Dec 15, 2004

Small White Dragon posted:

I'm developing a command line OS X utility in Xcode.

Is there a way to get Xcode to put resources with the resultant binary for testing purposes?

When I run it in 4.3.1, sometimes the debugger window at the bottom vanishes as soon as the utility has finished running -- which is annoying, since I wanted to see its output. Any idea how I can get fix this?

Command line stuff is pretty much mach-o (like linux's elf) is a single-stream file, so you'll need to put your support resources somewhere hardwired, or perhaps specified in a .ini file or something.

~/Library/Application Support/<your app> is as good a place as any.

Keep in mind .app files are actually just little directorys of files with some mac-gui magic to make them pretend to be a single file.

You *could* put it relative to the binary and then use a symlink to hook it to /usr/bin if you wish. That'd probably work I guess.

fankey
Aug 31, 2001

I'm looking for a way to make a custom UIScrollView be 'virtualizing' but still be able to masquerade as a normal UIScrollView. By virtualizing I mean that it loads only the view that is visible ( +- a few pages ) and discards/loads views while the user is scrolling. I can override addSubView: and shove the views into my own collection but then subViews.count isn't in sync anymore and removeFromSuperview: doesn't remove them from my internal collection. Is there a way to make this work? Am I going about this the wrong way?

Here's my current code which uses dummy UIViews in place of the offscreen views. This doesn't work but shows what I'm going for.
code:
@implementation CustomScrollView

@synthesize currentPage;

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view
{
  BOOL ret = YES;
  if( [view respondsToSelector:@selector(acceptTouch)] )
  {
    ret = [[view performSelector:@selector(acceptTouch)] boolValue];
  }
  else ret = [super touchesShouldBegin:touches withEvent:event inContentView: view];
  return ret;
}

-(void)invalidateLayout
{
  _LastSize = CGSizeMake(0,0);
  [self layoutSubviews];
}

-(void) addSubview:(UIView *)view
{
  if( !allItems ) allItems = [[[NSMutableArray alloc] init] retain];
  [allItems addObject:view];
  // first page is special and is always there
  if( allItems.count == 1 )
  {
    [super addSubview:view];
  }
  else
  {
    [super addSubview:[[UIView alloc] init]];
  }
}

- (void)layoutSubviews
{
  // layout our subviews so they fill the screen
  CGSize sz = self.frame.size;
  if( _LastSize.width != sz.width || _LastSize.height != sz.height )
  {
    _LastSize = sz;
    CGSize sz = self.frame.size;
    double x = 0;
    for(UIView* view in self.subviews)
    {
      view.frame = CGRectMake( x, 0, sz.width, sz.height);
      x += sz.width;
    }
    self.contentSize = CGSizeMake(x, self.frame.size.height);
    [self setContentOffset:CGPointMake(sz.width*currentPage,0) animated:NO];
    currentPage = currentPage;
  }
}

-(void)setCurrentPage:(int)value
{
  currentPage = value;
  for( int ix = 0; ix < allItems.count; ++ix)
  {
    bool showPage = ix == 0 || (abs(ix - currentPage -1 ) < 2 );
    if( showPage )
    {
      // check to see if this page is alread in our subviews,
      // if not remove what's already there and add our view
      if( [allItems objectAtIndex:ix] != [self.subviews objectAtIndex:ix] )
      {
        [[self.subviews objectAtIndex:ix] removeFromSuperview];
        [self insertSubview:[allItems objectAtIndex:ix] atIndex:ix];
      }
    }
    else
    {
      // check if one of our views is now off screen and
      // needs to be removed
      if( [allItems containsObject:[self.subviews objectAtIndex:ix]] )
      {
        [[self.subviews objectAtIndex:ix] removeFromSuperview];
        [self insertSubview:[[UIView alloc] init] atIndex:ix];
      }
    }
  }
  _LastSize = CGSizeMake(0,0);
  [self layoutSubviews];
}

-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
  CGFloat pageWidth = self.frame.size.width;
  float fractionalPage = self.contentOffset.x / pageWidth;
  NSInteger nearestNumber = lround(fractionalPage);
  if( nearestNumber != currentPage ) self.currentPage = nearestNumber;
}

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Check out the Advanced ScrollView Techniques WWDC 2011 session.

fankey
Aug 31, 2001

pokeyman posted:

Check out the Advanced ScrollView Techniques WWDC 2011 session.
Thanks. While not exactly what I was looking for it did contain a few helpful techniques.

I have another question about image caching. Say I implement an image cache based on image URL and have the ability to assign weight to each cache entry. Using this weight I can order which images I would want to delete from my cache first - in my case that would be pages furthest from the currently viewed one. It seems like the right approach would be to hook didReceiveMemoryWarning and delete there. The issue is how to I now how much to delete? Ideally I don't want to delete all my images - just enough to allow me to continue to run. If I do a pass and delete the least weighted ones will I get another message letting me know I should do another pass?

Another thought I had was to just reserve a given amount of memory for the images and delete based on that. It seems a little slimy but in theory I think would work. I'd still need to clear out my cache when I get didReceiveMemoryWarning but that would just blow away everything requiring things to redownload if necessary.

Small White Dragon
Nov 23, 2007

No relation.

duck monster posted:

Command line stuff is pretty much mach-o (like linux's elf) is a single-stream file, so you'll need to put your support resources somewhere hardwired, or perhaps specified in a .ini file or something.

~/Library/Application Support/<your app> is as good a place as any.

Keep in mind .app files are actually just little directorys of files with some mac-gui magic to make them pretend to be a single file.

You *could* put it relative to the binary and then use a symlink to hook it to /usr/bin if you wish. That'd probably work I guess.
I'm aware of the structure, I just wanted to know if I could get Xcode to copy test files into the same directory rather than hardcoding a bunch of paths in the binary.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

fankey posted:

I have another question about image caching. Say I implement an image cache based on image URL and have the ability to assign weight to each cache entry. Using this weight I can order which images I would want to delete from my cache first - in my case that would be pages furthest from the currently viewed one. It seems like the right approach would be to hook didReceiveMemoryWarning and delete there. The issue is how to I now how much to delete? Ideally I don't want to delete all my images - just enough to allow me to continue to run. If I do a pass and delete the least weighted ones will I get another message letting me know I should do another pass?

Another thought I had was to just reserve a given amount of memory for the images and delete based on that. It seems a little slimy but in theory I think would work. I'd still need to clear out my cache when I get didReceiveMemoryWarning but that would just blow away everything requiring things to redownload if necessary.

As far as I know there's no good way to figure out how much memory to free up on a memory warning–the OS will just terminate you if you don't free enough. I think the idea is you completely empty all memory caches on a memory warning.

I recommend you use an on-disk cache in your app's Caches folder (so iCloud/backup doesn't pick it up) and just load every image from disk. Let UIImageView deal with memory warnings, and let iOS purge the caches folder for you. One of several libraries that might help: AsyncImageView

duck monster
Dec 15, 2004

Small White Dragon posted:

I'm aware of the structure, I just wanted to know if I could get Xcode to copy test files into the same directory rather than hardcoding a bunch of paths in the binary.

Just add a build stage on and I dunno, maybe a shell script to do it or something.

You can really customise that build sequence any way you want. Hell, attach an X10 power controller and stick "Make a coffee" as your final build phase if you want.

fankey
Aug 31, 2001

pokeyman posted:

As far as I know there's no good way to figure out how much memory to free up on a memory warning–the OS will just terminate you if you don't free enough. I think the idea is you completely empty all memory caches on a memory warning.

I recommend you use an on-disk cache in your app's Caches folder (so iCloud/backup doesn't pick it up) and just load every image from disk. Let UIImageView deal with memory warnings, and let iOS purge the caches folder for you. One of several libraries that might help: AsyncImageView
I didn't think of loading to disk - that seems like a good idea. Unfortunately AsyncImageView has that on their TODO list. Nimbus looks like it supports that but it looks a big mess of stuff - not sure if I want to get into that. It doesn't seem like it'll be too hard to roll my own for the simple features I need. Thanks.

Toady
Jan 12, 2009

Clang docs for Objective-C literals are online: http://clang.llvm.org/docs/ObjectiveCLiterals.html

dizzywhip
Dec 23, 2005

:aaa: That is gonna be so awesome.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
No @NULL :-(

Zhentar
Sep 28, 2003

Brilliant Master Genius
Container literals? poo poo yes.

Doc Block
Apr 15, 2003
Fun Shoe
:hellyeah:

Any idea why they didn't just go with plain ol' objectAtIndex: or objectForKey: though? It'd be nice to be able to write code that uses container subscripts and still runs on 10.6/7 and iOS 5. (I'm assuming that these will come along with Xcode 4.4 and iOS 6 / OS X 10.8)

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
I believe that should actually still work via the same sort of implicitly-linked-archive magic that ARC used.

The frameworks teams asked us not to use the same selectors so that they could have the leeway to change behavior for subscript expressions without changing behavior for the existing methods. Plus there is some possibility of other classes taking advantage of the syntax without wanting to declare methods they consider inappropriate.

Carthag Tuek
Oct 15, 2005

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



Doc Block posted:

:hellyeah:

Any idea why they didn't just go with plain ol' objectAtIndex: or objectForKey: though? It'd be nice to be able to write code that uses container subscripts and still runs on 10.6/7 and iOS 5. (I'm assuming that these will come along with Xcode 4.4 and iOS 6 / OS X 10.8)

As I read it, it's so the behaviour of objectAtIndexedSubscript: that may be different from that of objectAtIndex:

Can't think up a reason to do that, but I guess this also means that you can implement objectAtIndexedSubscript: on your own classes and get the subscript behaviour for free?

duck monster
Dec 15, 2004

Toady posted:

Clang docs for Objective-C literals are online: http://clang.llvm.org/docs/ObjectiveCLiterals.html

Beats the poo poo out of the hosed up macros I was using before.

duck monster
Dec 15, 2004

pokeyman posted:

No @NULL :-(

:eng101:

#define NULLZ [NSNull null]

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
I had a sudden urge to start a contest where we all post our most complicated/ugly macros.... Then I realized that would be a contest where we all lose.

Toady
Jan 12, 2009

Leave it to the Objective-C mailing list to debate the innocuous existence of literal syntax.

Night141
Aug 4, 2007
Yes I swear, its me.
It's finally happened - Apple just started rejecting app submissions using the deprecated [UIDevice uniqeIdentifier]. I know multiple advertising networks and other API's are currently using that for user tracking across apps. Some people have suggested using UIPasteboard and creating a "bucket" for storing a UDID:

Apple Documentation posted:

Applications can also create pasteboards for their own use or for use by a family of related applications. Pasteboards must be identified by a unique names. You may also mark an application pasteboard as persistent, so that it continues to exist past the termination of the application and past system reboots. System pasteboards are persistent by default.

Honestly that seems iffy. Has anyone thought of other implementations/replacements?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Toady posted:

Leave it to the Objective-C mailing list to debate the innocuous existence of literal syntax.

Well, you know. It may be literal syntax today, but tomorrow NSArray will be a class template and 50% of every .m file will be a long series of declarations like
code:
@instantiate NSDictionary<NSString,MyController,@template(NSAllocator)>;
but it won't even improve type-safety because all the accessors will still return id.

Plus these literals don't just transparently work with my pointless hand-rolled collections framework. Surely this spells doom for all of Objective-C.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
And I've had enough with Apple locking me in to the open source compiler they stole (just like they stole WebKit) and as the only implementation of an Objective-C runtime and compiler ever created that's in a handy package in the app store I demand satisfaction.

xgalaxy
Jan 27, 2004
i write code

Night141 posted:

It's finally happened - Apple just started rejecting app submissions using the deprecated [UIDevice uniqeIdentifier]. I know multiple advertising networks and other API's are currently using that for user tracking across apps. Some people have suggested using UIPasteboard and creating a "bucket" for storing a UDID:


Honestly that seems iffy. Has anyone thought of other implementations/replacements?

You can use MAC address if you don't care about security, or don't care that jail broken devices can change it. Though I wouldn't be too terribly surprised if access to MAC gets restricted too, since it's an obvious fallback solution for ad tracking purposes.

If you need something like UDID, and all the apps you need it for are submitted by the same developer account, you can generate a UUID instead and store in a key chain group. All the applications would need to share the same app seed id.

Alternatively, if on IOS 5, you could check for ACAccountStore accounts, currently only twitter, and use that for identification purposes. This is obviously a very poor substitute since not everyone would have a twitter account, so you would need some sorta fallback plan.

Failing those things, it seems some combination of UIPasteboard and keychain store is the best option. Since keychain data is not removed when the app is uninstalled you can use this to your advantage. And then share whatever ID to our other apps via UIPasteboard. The obvious problem with this solution is if all the apps that rely on UIPasteboard are removed from the device, their pasteboards are removed, so any new app that wasn't previously installed will have no idea that an ID was already created.

Anyways, those are my thoughts.

Adbot
ADBOT LOVES YOU

ManicJason
Oct 27, 2003

He doesn't really stop the puck, but he scares the hell out of the other team.
Has anyone here ever messed with button input through the headphone jack?

I'd love to be able to add push-to-talk ability to a project I'm working on, but it looks like that may be difficult to do without forcing the user to unlock the touchscreen every time they want to talk. I see how to get UIEventTypeRemoteControl events for play/pause/seek, but it's a bit weird getting that set up (since you are supposed to be playing audio) and hold events probably won't work right.

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