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
Doc Block
Apr 15, 2003
Fun Shoe
Yep. At least, for iPhone you have to choose portrait or landscape.

Adbot
ADBOT LOVES YOU

lord funk
Feb 16, 2004

Thanks, I figured.

In other news: another MIDI controller now supports data streaming over USB. :wtf:? I thought that data transmission over USB was not allowed / possible, otherwise I'd have gone straight to that for TC-Data.

Doctor w-rw-rw-
Jun 24, 2008

lord funk posted:

Thanks, I figured.

In other news: another MIDI controller now supports data streaming over USB. :wtf:? I thought that data transmission over USB was not allowed / possible, otherwise I'd have gone straight to that for TC-Data.

At the very least, libusb2 works if you're jailbroken or licensed for MFi, I think, since you get access to the right frameworks. Never been in MFi though.

I know that a former coworker built communication over USB before for non-jailbroken apps using an open-source library and a server running on the computer, but I forget how he did it, and he never submitted to the App Store.

Doc Block
Apr 15, 2003
Fun Shoe
I just learned about Cocoa Bindings.

:vince:

So much glue code eliminated. Wonder if they'll ever make it to iOS.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
They're sweet but I remember hating debugging them when they go wrong. Though I was using Interface Builder at the time, and I generally had a worse understanding of all this stuff, so maybe that's an undeserved reputation in my mind.

I doubt we'll see an exact port but I could see something similar making its way over to iOS.

shodanjr_gr
Nov 20, 2007
I got a small Swift project for which i built a UI in Interface Builder with autolayout. My view has 3 subviews (a label, a UIImage view and a placeholder at the bottom). On runtime it looks like this:



which is as intended.

I hadn't touched the .storyboard file in a few days. I opened it today and the view appears like this:



I can still edit the views via the hierarchy to the left of the main IB window but their entries appear "greyed out". I can not select them or do anything to get them to render in the main content view.

Any clues as to what's going on?

e: I think i had somehow set up the views under one particular size class or something which caused them to not show up in other size classes.

shodanjr_gr fucked around with this message at 07:52 on Dec 7, 2014

brap
Aug 23, 2004

Grimey Drawer
Exactly what I was going to say. You can select the views in the document tree in your storyboard, then go to the bottom of the attributes inspector to enable them for all size classes

lord funk
Feb 16, 2004

:negative:

Not to be ignored, my TabBar has decided to poo poo itself into a frenzy. God forbid I work on something that isn't broken UIKit for once.

All three of these happen off of the same build. The third one is correct:


I'm sure it's due to the fact that I just want a solid color bar that doesn't have a tinting image, and I change the colors dynamically in the app. I also hide / show the tab bar myself. Now I'll just take that all apart to see what the tab bar is allergic to.

edit: seems like forcing a frame resize before it appears hacks it back to normal..

lord funk fucked around with this message at 18:52 on Dec 8, 2014

dizzywhip
Dec 23, 2005

Anyone know if there's a way to temporarily disable NSBeeps? I have a view that calls interpretKeyEvents on itself, and that method beeps whenever an event that it doesn't handle is passed in. I pass unhandled events up the responder chain, so when something further up the chain handles the event, I get a beep on valid input. I put a break point on NSBeep, and it's being called directly from interpretKeyEvents, so it doesn't look like there's any method in-between that I could potentially override.

Doctor w-rw-rw-
Jun 24, 2008

lord funk posted:

edit: seems like forcing a frame resize before it appears hacks it back to normal..

I have the feeling that if I asked for more details on why this is the case, I'd be cringing in horror. This doesn't seem normal.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I'm not missing the super secret documentation that says "NSUserDefaults does KVO" right? It's just a thing that happens to work right now?

And I don't mean the controller on OS X, I mean good ol' NSUserDefaults.

lord funk
Feb 16, 2004

Doctor w-rw-rw- posted:

I have the feeling that if I asked for more details on why this is the case, I'd be cringing in horror. This doesn't seem normal.

Is it a horror that I subclass UITabBar so that I can react to color change notifications? It's the only thing I can think of that's really out of the ordinary.

In other news, iTunes Connect doesn't see my latest build upload, but re-uploading it complains that it already exists. :geno:

Doc Block
Apr 15, 2003
Fun Shoe

pokeyman posted:

I'm not missing the super secret documentation that says "NSUserDefaults does KVO" right? It's just a thing that happens to work right now?

And I don't mean the controller on OS X, I mean good ol' NSUserDefaults.

Since the Cocoa bindings controllers work via KVO and KVC, I would say that yes, good ol' NSUserDefaults works with KVO.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Doc Block posted:

Since the Cocoa bindings controllers work via KVO and KVC, I would say that yes, good ol' NSUserDefaults works with KVO.

Cocoa Bindings uses NSUserDefaultsController though, which is unavailable on iOS. Whereas I just noticed people saying NSUserDefaults itself complies with KVO but I can't find any documentation about that.

Doc Block
Apr 15, 2003
Fun Shoe
Yes, but the controllers do their thing with KVC and KVO. So I imagine that, at least on OS X, NSUserDefaults has worked with both KVO and KVC for quite some time.

And if it does on OS X, surely there's no reason it wouldn't also work on iOS, right? :laugh:

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
It's apparently a recent change though, one which NSUserDefaultsController predates by several years. Whether it uses KVO internally is an implementation detail; it would be pretty easy to remake it using just NSUserDefaultsDidChangeNotification, for example.

Doc Block
Apr 15, 2003
Fun Shoe
IDK. My understanding is that bindings controllers use KVO and KVC.

In any case, I just wrote up a little test app and yep, NSUserDefaults works with KVO and KVC. Tested it on iOS 7.1 and it worked fine, so it's at least been around that long.

Doc Block fucked around with this message at 01:29 on Dec 10, 2014

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

Doc Block posted:

IDK. My understanding is that bindings controllers use KVO and KVC.

In any case, I just wrote up a little test app and yep, NSUserDefaults works with KVO and KVC. Tested it on iOS 7.1 and it worked fine, so it's at least been around that long.

So many times I just write a test app and answer the question with far more clarity than a mountain of documentation.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I think we're just talking past each other. The binding controllers expose KVO keys for bindings, but they need not be implemented using KVO internally. Like I could make TimerController that calls didChangeValueForKey every five seconds. Its interface is KVO but its implementation is NSTimer.

Also I believe NSUserDefaults doesn't notify KVO when something changes via the Settings.bundle, whereas the notification posts, so it's not perfect.

Ender.uNF posted:

So many times I just write a test app and answer the question with far more clarity than a mountain of documentation.

Totally. In this case I knew it worked, I just wanted to know if it was documented so I could feel ok about using it.

Doc Block
Apr 15, 2003
Fun Shoe
Well yeah, you can implement your own controller however you'd like, but NSArrayController and NSObjectController do actually get and set values via KVO and KVC, and so it would stand to reason that so did NSUserDefaultsController.

Have a look at my test program: https://mega.co.nz/#!c8NgHT5C!BoNiOElO2dNzvEEFX2vIXiLbveeqXhjj0bwOvPejLw0

dizzywhip
Dec 23, 2005

Creating a test project to check whether part of AppKit supports KVO is not very meaningful. A lot of stuff in AppKit happens to work with KVO but isn't documented as such, and Apple has explicitly stated that you shouldn't rely on KVO working unless it's documented. In practice I think it's pretty unlikely that it'll break in the future, but it's possible. It could also work under certain circumstances but not others, so if you want to use unsupported KVO you'd need to be very careful about testing it thoroughly.

Doh004
Apr 22, 2007

Mmmmm Donuts...

lord funk posted:

In other news, iTunes Connect doesn't see my latest build upload, but re-uploading it complains that it already exists. :geno:

There's a definite lag between successful uploading and it showing up in iTunes Connect. Must be dependent on amount of submissions around that time.

Begby
Apr 7, 2005

Light saber? Check. Black boots? Check. Codpiece? Check. He's more machine than kid now.
Ok, making some progress on my first iOS app. (been mostly doing C# for the past few years). This syntax was pretty much japanese at first compared to every other language out there I have tried, but I am getting the hang of it.

The app is a pretty simple master/detail thing, and I used core-data for the items i need to display. So far I have it creating the records, and I have updated it to save a few fields.

I have created an entity subclass for my core-data entity, then I extended it with a category to add some calculated fields. Some of the calculated fields are readonly and just use some math depending on the values from the underlying core-data entity.

Other calculated fields are editable, when you edit one, it will adjust one or more of the field values from the underlying core-data entity.


Now, I can go ahead and just wire up a kajillion events so that when one value changes, it will call a refresh method to update all the values from the detail object and then save the context.

That seems a bit old school, so then I read up on KVO, and it appears I can set up an observer to update the values if a value changes. That doesn't sound too bad, is there something special i have to do with this category extension thing and the calculated fields? If say X changes, and that affects the value of Y (assuming Y is calculated and does not have an underlying field), do I need to trigger an event so that the observers of Y fire?

Doc Block
Apr 15, 2003
Fun Shoe
:siren: DANGER, IGNORE! :siren:

Doc Block fucked around with this message at 08:44 on Dec 11, 2014

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Begby posted:

That seems a bit old school, so then I read up on KVO, and it appears I can set up an observer to update the values if a value changes. That doesn't sound too bad, is there something special i have to do with this category extension thing and the calculated fields? If say X changes, and that affects the value of Y (assuming Y is calculated and does not have an underlying field), do I need to trigger an event so that the observers of Y fire?

KVO's got your back:

Objective-C code:

@interface Thing : NSManagedObject

@property (nonatomic) int32_t count;

@end

@interface Thing (CalculatedFields)

@property (readonly, nonatomic) BOOL positiveCount;

@end

@implementation Thing (CalculatedFields)

- (BOOL)positiveCount {
    return self.count > 0;
}

+ (NSSet *)keyPathsForValuesAffectingPositiveCount {
    return [NSSet setWithObject:@"count"];
}

@end

For more info, hit up the Key-Value Observing Programming Guide.

Begby
Apr 7, 2005

Light saber? Check. Black boots? Check. Codpiece? Check. He's more machine than kid now.
Excellent, thanks for the info guys, thats plenty to get me up and running.

Doctor w-rw-rw-
Jun 24, 2008

Doc Block posted:

Yes. Any custom setters need to call -willChangeValueForKey: before changing the value and then call -didChangeValueForKey: after changing it if you want it to work with KVO, since those are the methods that tell the KVO system when the values change.

:frogsiren: That information is wrong, disregard! :frogsiren:

Custom setters do not need to call -willChangeValueForKey: or -didChangeValueForKey: if they are KVC-compliant. What this means is that KVO on properties named like -setFoo: and -foo will work properly. KVO does this by creating a dynamic subclass.

Further reading on the mechanism, if you're interested.
Standard overview in Apple's docs here.
Concise explanation here.

brap
Aug 23, 2004

Grimey Drawer
I noticed that MKMapView annotation views can be rapidly selected by dragging one's finger. My didSelectAnnotationView function initiates a network request and various other expensive stuff, and I've noticed it affect the stability of the app when pushing the limits of this. I have been googling around but I can't find anything to prevent rapid selection by dragging. Any ideas?

Doc Block
Apr 15, 2003
Fun Shoe

pokeyman posted:

KVO's got your back:

Objective-C code:

+ (NSSet *)keyPathsForValuesAffectingPositiveCount {
    return [NSSet setWithObject:@"count"];
}

@end
For more info, hit up the Key-Value Observing Programming Guide.

:vince: :monocle: I had no idea you could do that.

Doctor w-rw-rw- posted:

:frogsiren: That information is wrong, disregard! :frogsiren:

Custom setters do not need to call -willChangeValueForKey: or -didChangeValueForKey: if they are KVC-compliant. What this means is that KVO on properties named like -setFoo: and -foo will work properly. KVO does this by creating a dynamic subclass.

Further reading on the mechanism, if you're interested.
Standard overview in Apple's docs here.
Concise explanation here.

Wow. My bad. Dunno what I was thinking.

Doc Block fucked around with this message at 08:52 on Dec 11, 2014

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Doctor w-rw-rw- posted:

:frogsiren: That information is wrong, disregard! :frogsiren:

Custom setters do not need to call -willChangeValueForKey: or -didChangeValueForKey: if they are KVC-compliant. What this means is that KVO on properties named like -setFoo: and -foo will work properly. KVO does this by creating a dynamic subclass.

Further reading on the mechanism, if you're interested.
Standard overview in Apple's docs here.
Concise explanation here.

This is true when automatic KVO is enabled for the given key (which it is by default). Classes can disable automatic KVO notification by implementing +automaticallyNotifiesObserversOf<Key> or +automaticallyNotifiesObserversOfKey: and returning NO.

The relevant, notable example of a class that does this is NSManagedObject, which returns NO for (and only for) its managed properties. So if you're making a custom accessor for a modelled property, you still need to send -willChangeValueForKey: and -didChangeValueForKey:.

KVO is awesome but it can get complicated.

ManicJason
Oct 27, 2003

He doesn't really stop the puck, but he scares the hell out of the other team.
drat, pokeyman and Doctor w-rw-rw- both laying down the KVO knowledge. I did not know either of those things.

I've written so many willChangeValueForKey lines that were for naught. :saddowns:

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
KVO is also a fast path to a zombie if you don't clean up properly. It's also really helpful in that it doesn't have any automatic cleanup, nor any way to check for observers so you'd better track it correctly.

We have a helper that uses an associated object behind the scenes to make sure all observers are nilling references and stuff gets cleaned up on dealloc.

lord funk
Feb 16, 2004

Using Quicktime Player + Lightning cable to capture iPad would be sweet it it didn't crash every 75 seconds.

kitten smoothie
Dec 29, 2001

http://blogs.msdn.com/b/somasegar/a...dows-phone.aspx

Here's hoping an acquired HockeyApp will keep delivering on iOS, because unless you're grandfathered into the old TestFlight, HockeyApp was the next best thing for CI-driven beta builds.

Just-In-Timeberlake
Aug 18, 2003

shodanjr_gr posted:

I got a small Swift project for which i built a UI in Interface Builder with autolayout. My view has 3 subviews (a label, a UIImage view and a placeholder at the bottom). On runtime it looks like this:



which is as intended.

I hadn't touched the .storyboard file in a few days. I opened it today and the view appears like this:



I can still edit the views via the hierarchy to the left of the main IB window but their entries appear "greyed out". I can not select them or do anything to get them to render in the main content view.

Any clues as to what's going on?

e: I think i had somehow set up the views under one particular size class or something which caused them to not show up in other size classes.

literally was just coming in here to ask about this same problem, now solved.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

kitten smoothie posted:

http://blogs.msdn.com/b/somasegar/a...dows-phone.aspx

Here's hoping an acquired HockeyApp will keep delivering on iOS, because unless you're grandfathered into the old TestFlight, HockeyApp was the next best thing for CI-driven beta builds.

I'm hoping the magical Microsoft dollars make HockeyApp freeeeeee

HiriseSoftware
Dec 3, 2004

Two tips for the wise:
1. Buy an AK-97 assault rifle.
2. If there's someone hanging around your neighborhood you don't know, shoot him.
Please clarify for my own sanity regarding iTunes Connect and screenshots - I'm using Safari on OSX, and the order that I'm uploading them is the REVERSE of how they would appear on the store, correct? Each next upload is placed to the left of the previous screens, so it makes sense to me that I'd have to rearrange them manually to how I'd want them to look. Googling is not entirely clear on this.

Doc Block
Apr 15, 2003
Fun Shoe
They will appear in the order you see on iTunes Connect. While the one you upload last will appear furthest to the left initially, you can always just drag them to whatever order you want.

King of Gulps
Sep 4, 2003

I've been having some weird autocomplete problems (on 6.1.1) that I can't reproduce reliably; it has happened twice in my current project, in individual .h/.m pairs only (rather than the whole project), and results in an autocomplete window popping up with no type information on the left side and a seemingly random selection of keywords. The only commonality that I could see was that both sets of files were the only ones in my (small) project with an NS_ENUM declaration in the .h; however, I couldn't get another similar class to fail so :confused:
Already tried deleting derived data and cleaning etc. Deleting the files, creating identically named ones, and pasting the code back in fixed it completely.

Adbot
ADBOT LOVES YOU

lord funk
Feb 16, 2004

How come I can cmd-shift-o a thousand times to the file I want and it won't remember, but one miss-click on TrackCleanApertureDimensions (Quicktime->MovieFormats.h:477) and it's the new top hit! That's the file you wanted, right!? *pant* *pant* *pant*

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