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

I just spent the whole morning figuring out why I suddenly had to register Nibs for my UITableViewCell reuseIdentifiers. Turns out the template for UITableViewControllers replaces this:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

with this:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

The latter is iOS 6 only, and requires you to register the identifier manually, with a class or Nib to use as a default. Is there any advantage to that?

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
It avoids the whole if (!cell) cell = [[UITableViewCell alloc] initblahblah...] dance in your data source.

I'm not sure but I have a hunch that's also the machinery used when you give a table cell prototypes in a storyboard.

Kallikrates
Jul 7, 2002
Pro Lurker
The cells are also reused when they scroll off, and that is the mechanism to get an old one to reuse, or create a new one.

duck pond
Sep 13, 2007

Doc Block posted:

Clarified your example.

Calling GCD directly is fine for one-off instances of needing to perform something off the main thread, but for anything where you're adding a bunch of stuff to a background queue you're better off making your own queue(s) and using NSOperationQueue to manage them because you can cancel execution of that queue and whatnot.

Also, be careful with dispatch_sync(). Trying to use it to add a block to the calling thread will cause a deadlock.

thanks Doc Block and pokeyman! :cool:

tarepanda
Mar 26, 2011

Living the Dream
For anyone looking to learn about auto layouts, I found session 220 to be incredibly elementary and a waste of time; session 228 is much faster-paced and worthwhile.

Personal gripes: the woman in 220 has lots of pauses, repeats herself, and giggles a lot.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Bumping playback speed to 1.5x or even 2x can help a ton.

tarepanda
Mar 26, 2011

Living the Dream

pokeyman posted:

Bumping playback speed to 1.5x or even 2x can help a ton.

Then I can't really understand what's going on (hearing impairment) and I can't seem to find subtitles.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Oh, that's definitely not very helpful then. A transcript/subtitles would be fantastic.

ManicJason
Oct 27, 2003

He doesn't really stop the puck, but he scares the hell out of the other team.
Of course, immediately after complimenting Xcode 4.5 in this thread, I've gotten one of my projects into a state where it will not run in the debugger at all. It's the wonderful no such file or directory error which lists the valid path to your debug executable and can be caused by about 200 different things I am now going through one by one after a standard fuxcode/restarting everything had no effect.

Small White Dragon
Nov 23, 2007

No relation.
Anybody know of a way to get a modal UINavigationController (and its children) to re-lay themselves out after hiding/showing the statusbar?

Hughlander
May 11, 2005

Where can I find documentation about what happens when the on screen keyboard is up and someone presses the voice input button? Like what happens with the app's volume? I see some (all?) apps lower the volume at that point, is that the system or the app responding to a delegate call? What about returning volume when the input is done?

Doc Block
Apr 15, 2003
Fun Shoe

ManicJason posted:

Of course, immediately after complimenting Xcode 4.5 in this thread, I've gotten one of my projects into a state where it will not run in the debugger at all. It's the wonderful no such file or directory error which lists the valid path to your debug executable and can be caused by about 200 different things I am now going through one by one after a standard fuxcode/restarting everything had no effect.

Make sure Xcode is closed when you do fuxcode. I don't know about 4.5, but often (always?) Xcode 4.4 would lock your projects derived data directory (or something) so that it couldn't be deleted.

LP0 ON FIRE
Jan 25, 2006

beep boop

Froist posted:

I don't think this is that strange is it? I did the same (but with a static UIImage) on a game I finished recently.

It just depends on what your reasoning is. It may sound strange to use UIImages on a transparent Cocos2D because Cocos2D already comes bundled with stuff for gradients and parallax backgrounds.

ManicJason
Oct 27, 2003

He doesn't really stop the puck, but he scares the hell out of the other team.

Doc Block posted:

Make sure Xcode is closed when you do fuxcode. I don't know about 4.5, but often (always?) Xcode 4.4 would lock your projects derived data directory (or something) so that it couldn't be deleted.

Yeah, it was. After doing all of the normal steps a few times over and in different orders, it finally fixed itself after doing a clean, quitting Xcode, doing a git clean, fuxcode, shutting off the iPad, shutting down the OSX box, and bringing everything back up. Standard Xcode.

Doc Block
Apr 15, 2003
Fun Shoe
I've been very fortunate in that I don't have issues with Xcode very often. And when they do crop up, restarting Xcode usually fixes the problem.

lord funk
Feb 16, 2004

Doc Block posted:

I've been very fortunate in that I don't have issues with Xcode very often. And when they do crop up, restarting Xcode usually fixes the problem.

It has gotten so much better than the early 4.x versions.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Why are loving iPad storyboards impossible to use even on my 27" monitor?

Literally the only benefit over nibs is you can see "ok, this view can lead to that view". But since you can't actually EDIT anything (not to mention see anything) unless you're zoomed way the gently caress in, you basically never use an overview.

They're fine for iPhone but wow, they don't add a lot to the iPad party.

tarepanda
Mar 26, 2011

Living the Dream
Yeah, it drives me insane that I can't select a level of magnification.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Trying to do that on a 1680x1050 MBP makes me want to slice my face off. I only started doing iOS dev work when Xcode 4 came out and a buddy of mine said that in 3 there was a magnification option that they removed when dealing with nibs that they removed. Is that true?

kitten smoothie
Dec 29, 2001

kitten smoothie posted:

Can I keep using 4.4 to build, put the Default-568h@2x.png file in there, and that's all it would take to force it to run in tall mode on an iPhone 5? Then if I'm being smart enough about laying out my UI relative to the window size, everything'd be great on either device?

Or do I need to actually build against 4.5 and the iOS 6 SDK?

For what it's worth, it looks like you can in fact do this. So I can at least still keep supporting armv6 devices this way until I absolutely need to use an iOS 6 feature. If you build in 4.4 and include the 568h launch image, the phone will still stretch things properly.

I just had to fix autoresize on some of my UI elements and everything looks just dandy on an iPhone 5.

I couldn't use 4.4 to debug on an iPhone 5, so I had to do all that in 4.5. But then I could go and do an ad-hoc build in 4.4 with armv7 and armv6 support and have it work on the iPhone 5. Have not tried submitting to the store like this but probably will do that next week.

Doc Block
Apr 15, 2003
Fun Shoe
Do people really care that badly about supporting the iPhone and iPhone 3g? Even the 3GS has an ARMv7 CPU.

Plorkyeran
Mar 22, 2007

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

Doc Block posted:

Do people really care that badly about supporting the iPhone and iPhone 3g? Even the 3GS has an ARMv7 CPU.
No third-party apps on the original iPhone, so just the 3G.

The more relevant part is that Apple used to not allow removing armv6 support in an update. Has that changed?

kitten smoothie
Dec 29, 2001

Doc Block posted:

Do people really care that badly about supporting the iPhone and iPhone 3g? Even the 3GS has an ARMv7 CPU.
As I mentioned before it's mainly a business reason in my case, that the app I have is connected with a nonprofit and some of the people prefer giving money to us and not to Apple to buy new devices. I'd like to keep them happy by keeping the app running for them if I can.

I am more wanting to keep the 3G and the 2nd gen iPod Touch supported. The 3G is a 4 year old device, but they did sell it up until the 4 launched so there are at least some people who only recently came off a 2-year contract to buy it.

Honestly though I have just one more feature update on the app to roll out and then assuming it needs no bug fixes, it'll be the end of the line for those old devices. I was just hoping to also bundle in iPhone 5 compatibility at the same time.

Plorkyeran posted:

The more relevant part is that Apple used to not allow removing armv6 support in an update. Has that changed?
As I understand it, if you set the deployment target to 4.3 or later, you can drop armv6 in an update. 4.3 will not run on any armv6 device.

kitten smoothie fucked around with this message at 05:02 on Sep 26, 2012

Doc Block
Apr 15, 2003
Fun Shoe

Plorkyeran posted:

No third-party apps on the original iPhone, so just the 3G.

The more relevant part is that Apple used to not allow removing armv6 support in an update. Has that changed?

Yes. I submitted an update that took the app from armv6 & armv7 to just armv7 with no problems. It just depends on your deployment target. Was also moving the app to only support iOS 5+ anyway, so it wasn't a big deal.

BTW, the original iPhone also got the App Store when "iPhone OS" 2.0 came out.

Carthag Tuek
Oct 15, 2005

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



Why do I get an hour added here?

Objective-C code:
(lldb) po theDate
(NSDate *) $0 = 0x418ac777f800000d 2002-10-12 23:59:59 +0000
(lldb) po ageComponents
(NSDateComponents *) $1 = 0x0000000104c03fb0 <NSDateComponents: 0x104c03fb0>
    TimeZone: GMT (GMT) offset 0
    Calendar Year: 12
    Month: 3
    Leap month: no
    Day: 0
    Hour: 0
(lldb) po (NSDate *)[(NSCalendar *)self.calendar dateByAddingComponents:ageComponents toDate:theDate options:0]
(NSDate *) $2 = 0x41ba64a58f00000d 2015-01-13 00:59:59 +0000
E: I set up ageComponents like this, where age is an object that returns NSUInteger for years/months/days properties:
Objective-C code:
    NSDateComponents *ageComponents = [[NSDateComponents alloc] init];
    
    [ageComponents setYear:[age years]];
    [ageComponents setMonth:[age months]];
    [ageComponents setDay:[age days]];
    [ageComponents setHour:0];
    [ageComponents setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];

Carthag Tuek fucked around with this message at 16:41 on Sep 26, 2012

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
Just in case any of you still get the infuriating bootstrap error where you have to reboot your Mac to run in the simulator, here is a fix:

http://www.mikeash.com/pyblog/solving-simulator-bootstrap-errors.html

Short version is:
launchctl list|grep UIKitApplication|awk '{print $3}'|xargs launchctl remove

Doesn't work on the device unfortunately so you'll still have to reboot that but it's far less annoying than rebooting your Mac (though the SSD has helped a ton with that*)


* Seriously, get an SSD. The difference it makes is insane. It makes my life as a developer easier every day. It makes Xcode seem silky smooth with no stuttering.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Carthag posted:

Why do I get an hour added here?

Objective-C code:
(lldb) po theDate
(NSDate *) $0 = 0x418ac777f800000d 2002-10-12 23:59:59 +0000
(lldb) po ageComponents
(NSDateComponents *) $1 = 0x0000000104c03fb0 <NSDateComponents: 0x104c03fb0>
    TimeZone: GMT (GMT) offset 0
    Calendar Year: 12
    Month: 3
    Leap month: no
    Day: 0
    Hour: 0
(lldb) po (NSDate *)[(NSCalendar *)self.calendar dateByAddingComponents:ageComponents toDate:theDate options:0]
(NSDate *) $2 = 0x41ba64a58f00000d 2015-01-13 00:59:59 +0000
E: I set up ageComponents like this, where age is an object that returns NSUInteger for years/months/days properties:
Objective-C code:
    NSDateComponents *ageComponents = [[NSDateComponents alloc] init];
    
    [ageComponents setYear:[age years]];
    [ageComponents setMonth:[age months]];
    [ageComponents setDay:[age days]];
    [ageComponents setHour:0];
    [ageComponents setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];

For what it's worth, I see a time zone change that I can't immediately explain (current locale is Mountain Daylight Time, current calendar Gregorian):

code:
irb(main):002:0> date = NSDate.dateWithString("2002-10-12 23:59:59 +0000")
=> 2002-10-12 17:59:59 -0600
irb(main):003:0> parts = NSDateComponents.new
=> #<NSDateComponents:0x400cfe640>
irb(main):004:0> parts.year = 12
=> 12
irb(main):005:0> parts.month = 3
=> 3
irb(main):008:0> parts.timeZone = NSTimeZone.timeZoneWithAbbreviation("UTC")
=> #<__NSTimeZone:0x400a8fe80>
irb(main):009:0> NSCalendar.currentCalendar.dateByAddingComponents(parts, toDate:date, options:0)
=> 2015-01-12 17:59:59 -0700
edit: I'm a liar, I'm on summer time. loving DST.

pokeyman fucked around with this message at 20:14 on Sep 26, 2012

the Steve
Dec 21, 2004

I see what you're doing there.
Hi - is it possible to include information like text messages or alarms within an app? For example, could you have a text message appear within a game?

I know by default they are set not to interrupt a running app, but I was wondering if there's a way to include those notifications within an app in a new way.

Doc Block
Apr 15, 2003
Fun Shoe
No, those are (rightly) outside the application's control.

Carthag Tuek
Oct 15, 2005

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



pokeyman posted:

For what it's worth, I see a time zone change that I can't immediately explain (current locale is Mountain Daylight Time, current calendar Gregorian):

code:
irb(main):002:0> date = NSDate.dateWithString("2002-10-12 23:59:59 +0000")
=> 2002-10-12 17:59:59 -0600
irb(main):003:0> parts = NSDateComponents.new
=> #<NSDateComponents:0x400cfe640>
irb(main):004:0> parts.year = 12
=> 12
irb(main):005:0> parts.month = 3
=> 3
irb(main):008:0> parts.timeZone = NSTimeZone.timeZoneWithAbbreviation("UTC")
=> #<__NSTimeZone:0x400a8fe80>
irb(main):009:0> NSCalendar.currentCalendar.dateByAddingComponents(parts, toDate:date, options:0)
=> 2015-01-12 17:59:59 -0700
edit: I'm a liar, I'm on summer time. loving DST.

Yeah, DST... After some more digging, setting the calendar's timezone to UTC fixed it.

I just changed it directly on my calendar object (which isn't currentCalendar, I'm not sure whether that would have sideeffects, but could be dangerous) and got the right result.

the Steve
Dec 21, 2004

I see what you're doing there.

Doc Block posted:

No, those are (rightly) outside the application's control.

thanks!

tarepanda
Mar 26, 2011

Living the Dream
Why the heck hasn't Apple made a pull segue or added options for push right/left?

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

Doc Block posted:

No, those are (rightly) outside the application's control.

Why do you consider that "right?" I mean, I accept that it's the reality of the iPhone, but I still prefer a permissions-based system like Android allows.

Doc Block
Apr 15, 2003
Fun Shoe
Because it's what's best for the user. A list of permissions you have to browse through and check off isn't very user friendly, and like UAC in Windows Vista, just leads to users getting annoyed and agreeing to everything.

What's best or easiest for developers should come second to what's best for the users.

Small White Dragon
Nov 23, 2007

No relation.
I'm trying NSMetadataQuery to let iCloud let me know of updates.

However:
code:
            query.predicate = [NSPredicate predicateWithFormat:@"%K LIKE '*'", NSMetadataItemFSNameKey];
            query.searchScopes = [NSArray arrayWithObject:
                                  NSMetadataQueryUbiquitousDocumentsScope];
            
            // Subscribe to query updates
            [[NSNotificationCenter defaultCenter] addObserverForName:
             NSMetadataQueryDidUpdateNotification  .....
only seems to let me know when files are added/deleted, and not when they're updated.

Any suggestions?

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

Doc Block posted:

Because it's what's best for the user. A list of permissions you have to browse through and check off isn't very user friendly, and like UAC in Windows Vista, just leads to users getting annoyed and agreeing to everything.

What's best or easiest for developers should come second to what's best for the users.

You don't need to do anything beyond clicking "Install" once Android tells you what permission the app requests. While that is indeed slightly more work than simply clicking install, it has to be balanced by the fact that, on iPhone, if you don't like the default text messaging app, there's nothing you can do about it because Apple is the only one who can do anything with text messages.

I understand that there's reasons why Apple does what it does, but I don't think that any single approach is definitively wrong or right.

Doc Block
Apr 15, 2003
Fun Shoe

PT6A posted:

You don't need to do anything beyond clicking "Install" once Android tells you what permission the app requests. While that is indeed slightly more work than simply clicking install, it has to be balanced by the fact that, on iPhone, if you don't like the default text messaging app, there's nothing you can do about it because Apple is the only one who can do anything with text messages.

I understand that there's reasons why Apple does what it does, but I don't think that any single approach is definitively wrong or right.

So the user doesn't even get the option of telling the app "No" for certain permissions? Accept everything or don't install the app at all?

Sorry, but you aren't really selling me on Android here.

kitten smoothie
Dec 29, 2001

To be fair, up until iOS 6, apps could silently scrape your contacts and other data (see also: Path).

It is nice that now users have granular control of that, and it prompts the user at runtime when the app wants to actually use that info.

Doc Block
Apr 15, 2003
Fun Shoe
Which was an oversight. iOS apps have always had to ask for permission to access your location, photos, bug you with push notifications, etc., and have had to do it separately, and users can always say no.

Adbot
ADBOT LOVES YOU

Doh004
Apr 22, 2007

Mmmmm Donuts...
Been doing iOS work for the past 2 weeks so I'm still new and I've hit a roadblock:

I have a UILabel with a set width and height (let's say 50x50). I want said label to have only 2 lines of text. I do not want any word wrapping. I want this text to scale so that the text will fit within the UILabel's dimensions with two lines.

I've set numberOfLines, minimumFontSize, adjustsFontSizeToFitWidth as well as

code:
CGSize myNewSize = [myText sizeWithFont:self.myLabel.font constrainedToSize:CGSizeMake(50, 50)];

// Set the frame on the label to this new size height
Yet it's still truncating the text with ... . Can I disable line break some how? Or, am I doing something stupidly wrong? Thanks.

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