|
I still use -(IBAction)name:(id)sender; for some of my methods instead of -(void) even though I don't use IB. I like the clarity of seeing which methods are called directly with interface actions.
|
# ? Jan 23, 2012 21:59 |
|
|
# ? Jun 5, 2024 06:15 |
|
wellwhoopdedooo posted:Ah, the serialization (mostly) answers the question. I assume that there's some code that gets run in order to set the IBOutlet-type stuff in the ViewController classes (unless the ViewController instance is serialized too?) but, don't answer that parenthetical unless you know off the top of your head, I plan to research the details as soon as I get the chance. Outlet and action binding is handled by the nib loading code, not by the view controller. (Remember that this stuff is from the NeXTstep days.) The docs I linked earlier talk about how outlets get hooked up, so hit those up when you get a minute.
|
# ? Jan 23, 2012 22:29 |
|
Carthag posted:Nibs basically works through the NSCoding protocol. I'd actually really like Apple to push the IB custom plugin deal a bit more. One of the things that gave Delphi its power was the ability to write custom "Controls" that neatly encapsulated functionality behind a fairly clean interface that could be dragged-dropped and then wired in. This made life a LOT easier when doing big projects on delphi cos sites like Torys delphi site had thousands of these things, most with permissive open source licenses so it was easy to just drop a control in that, say, provided graphing or whatever, hook it up, and have a prototype in time for the lunch meeting with the client. Nothing I've seen, except maybe VB (which was a terrible terrible language) , was as productive as that. Having a big library of custom IB "controls" for iphone + mac work would be a huge productivity bonus for me. I mean theres plenty of *libraries* out there, but there always seems to be so much lovely boiler plate involved with using them.
|
# ? Jan 23, 2012 23:18 |
|
pokeyman posted:Why not make the sublayers the size of the actual rects they're drawing, position them appropriately, and then -hitTest: works? Yeah I just did that and cleaned up a bunch of model/view contaminations in the process. Lots neater. duck monster posted:I'd actually really like Apple to push the IB custom plugin deal a bit more. One of the things that gave Delphi its power was the ability to write custom "Controls" that neatly encapsulated functionality behind a fairly clean interface that could be dragged-dropped and then wired in. This made life a LOT easier when doing big projects on delphi cos sites like Torys delphi site had thousands of these things, most with permissive open source licenses so it was easy to just drop a control in that, say, provided graphing or whatever, hook it up, and have a prototype in time for the lunch meeting with the client. Nothing I've seen, except maybe VB (which was a terrible terrible language) , was as productive as that. Having a big library of custom IB "controls" for iphone + mac work would be a huge productivity bonus for me. I mean theres plenty of *libraries* out there, but there always seems to be so much lovely boiler plate involved with using them. Well I'm guessing their reasoning is that they prefer the usage of delegates and decoupling over subclassing, and they aren't fond of the idea of a thousand non-Mac-like controls floating around. They probably see it as a convenience for say a company that wants to be able to make it easier to split interface designers and coders into different teams, or something like that. Also I guess they aren't a thing in Xcode 4 anymore, I never really used them so sorry for bringing up deprecated tech if that's the case. Carthag Tuek fucked around with this message at 23:36 on Jan 23, 2012 |
# ? Jan 23, 2012 23:31 |
|
yeah thats true. The downside of the zillions of controls thing with delphi was it was a bit too easy to create wild and completely insane UIs for things (I literally created a bright pink barbie themed UI once for a clients app (motored industrial camera controller) I was trying to coax into severing our contract because I hated the oval office) and apple dont want that, plus yeah the delegate thing.
duck monster fucked around with this message at 01:51 on Jan 24, 2012 |
# ? Jan 24, 2012 01:45 |
|
OK, another probably really stupid ObjC question. I've got code that reads a CSV file in, and splits it into an array of arrays. Now, I need to go through the first line and figure out which columns contain which data. My plan was to set up an array with the possible values, and compare the value of each column to that. Finally, I'd have an NSMutableDictionary with the keys as the column names and the values be the columns containing that kind of data. The problem comes in trying to determine if the column value read in is part of the array. Here's my code: code:
|
# ? Jan 24, 2012 04:43 |
|
The "%@" format specifier means 'call [obj description]'. You're using it on a BOOL.
|
# ? Jan 24, 2012 04:50 |
|
What Zhentar said. You wantcode:
|
# ? Jan 24, 2012 04:54 |
|
Thanks. I don't know why it's the simple stuff that keeps tripping me up.
|
# ? Jan 24, 2012 05:04 |
|
The compiler should really be warning about that, sorry.
|
# ? Jan 24, 2012 05:41 |
|
This is a little weird: In an IKImageView subclass that I want to display an NSPopover in, and if I call it at the "wrong" time, I get an exception: Catchpoint 2 (exception thrown).2012-01-24 12:10:57.284 Test[71927:1403] -[NSPopover showRelativeToRect:ofView:preferredEdge:]: view has no window. You must supply a view in a window. I've overriden the view as follows to get some info as to why its window seems to be randomly nil: code:
2012-01-24 12:09:59.024 Test[71927:1403] viewWillMoveToWindow <NSWindow: 0x101d9b5b0> 2012-01-24 12:09:59.025 Test[71927:1403] viewDidMoveToWindow <NSWindow: 0x101d9b5b0> 2012-01-24 12:09:59.026 Test[71927:1403] removeFromSuperview <NSWindow: 0x101d9b5b0> 2012-01-24 12:09:59.026 Test[71927:1403] viewWillMoveToWindow (null) 2012-01-24 12:09:59.026 Test[71927:1403] viewDidMoveToWindow (null) 2012-01-24 12:09:59.028 Test[71927:1403] viewWillMoveToWindow <NSWindow: 0x101d9b5b0> 2012-01-24 12:09:59.028 Test[71927:1403] viewDidMoveToWindow <NSWindow: 0x101d9b5b0> 2012-01-24 12:09:59.028 Test[71927:1403] viewWillMoveToWindow (null) 2012-01-24 12:09:59.028 Test[71927:1403] viewDidMoveToWindow (null) The view remains visible and bindings etc are still active. It's just that it apparently no longer sits in the window (even though it looks like it). Is this some optimization trick? It may or may not do it a few times when first showing the window & view, sometimes with the view ending up with window = nil, sometimes not. I can't see a parttern to it. Edit: I can fix it by using its superview but that seems counterintuitive: code:
Carthag Tuek fucked around with this message at 12:35 on Jan 24, 2012 |
# ? Jan 24, 2012 12:22 |
|
So I've ported my first iPhone app over to being a Universal app to support iPad. It was a bit of a pain in the rear end as the documentation for doing so never seems to have been hammered down but I got it working and now I'm the proud parent of a really big app. However I ran into a bit of a snag involving orientation changing. The iPhone version only supports portrait but the iPad was so support either orientation. I know you can try to have the elements on the page auto-align, resize, and orient themselves through the visual editor but due to radically different portrait and landscape designs I decided to go the "two mains views in a single xib" route and have the app switch between the two when the device rotates. I'm doing that by code:
So my question is, on load, how do I set what the default view is? I thorugh the code from didRotateFromInterfaceOrientation into initWithNibName and viewDidLoad and nothing happened. Do I have to instantiate the default view somehow differently completely? I thought I read something about not using initWithNibName and using loadView instead but I'm not entirely sure how to hook all that up. This is the last thing I've got to take care of before I can wrap this up. Any ideas you awesome goons?
|
# ? Jan 25, 2012 16:05 |
|
Is there a way to find the type of an object's property using KVO? Basically, I've got a key and a string, and I need to know whether or not I need to parse that string into an NSNumber before calling -setValue: forKey:.
|
# ? Jan 25, 2012 19:37 |
|
Core Data Question: I'm syncing data with a server: I want to create new managed objects if they don't exist, and update ones if the modified date for the entity on the server is newer than the one on the device. I've read through this: http://developer.apple.com/library/.../TP40003174-SW1 Since I dont' have any relationship data here, it seems that their suggestion to "..create managed objects for the entire set and weed out (delete) any duplicates before save using a single large IN predicate" would be appropriate for adding new people. Question is, how do I do that? how do I then get the duplicates and update based on that timestamp? Core Data baffles me.
|
# ? Jan 25, 2012 19:41 |
|
Zhentar posted:Is there a way to find the type of an object's property using KVO? Basically, I've got a key and a string, and I need to know whether or not I need to parse that string into an NSNumber before calling -setValue: forKey:. As in you want to know what types it accepts? Usually that would be in the documentation, but I suppose you could do something like [[object valueForKey:@"key"] class] if you know it's an object and not a primitive or a struct.
|
# ? Jan 25, 2012 20:07 |
|
Yodzilla posted:So I've ported my first iPhone app over to being a Universal app to support iPad. It was a bit of a pain in the rear end as the documentation for doing so never seems to have been hammered down but I got it working and now I'm the proud parent of a really big app. loadView is for setting up your view hierarchy programmatically. Your viewController's view property and all your outlets will already be wired up by the time you get to viewDidLoad. So you could try copying the code from didRotateFromInterfaceOrientation to loadView and see if that works (don't forget to call [super loadView]).
|
# ? Jan 25, 2012 20:17 |
|
Carthag posted:As in you want to know what types it accepts? Usually that would be in the documentation, but I suppose you could do something like [[object valueForKey:@"key"] class] if you know it's an object and not a primitive or a struct. Yes, I want to know what type it accepts. And whether or not it's an object or a primitive is what I want to know most, so that method doesn't help me (it also doesn't help if the key you are setting is nil...). Although, looking at the documentation again, this isn't as big an issue for me as I thought - I thought that setting value types required you to pass an NSValue object, but that's not quite the case; rather, it calls the appropriate -<type>Value method on the object you pass, and NSString implements the -<type>Value methods that I'd need so I won't have to do any conversion in those cases.
|
# ? Jan 25, 2012 21:25 |
|
Doc Block posted:loadView is for setting up your view hierarchy programmatically. Your viewController's view property and all your outlets will already be wired up by the time you get to viewDidLoad. Yeah looks like no dice. Here's what I have: code:
code:
|
# ? Jan 25, 2012 22:23 |
|
Zhentar posted:Yes, I want to know what type it accepts. And whether or not it's an object or a primitive is what I want to know most, so that method doesn't help me (it also doesn't help if the key you are setting is nil...). This is almost certainly not what you want to do, but the runtime can tell you whether a property takes a primitive or an object. Take a look at the Objective-C Runtime Programming Guide, in the Declared Properties section. You can get a type string (aka what you get out of @encode) for a property, which you would then have to parse for the information you're looking for. Again, you probably don't want to do it this way, and you should look into NSValue boxing/unboxing and (if that doesn't work for you) key-value coding validation before you go parsing type strings.
|
# ? Jan 25, 2012 23:13 |
|
Yodzilla posted:Yeah looks like no dice. Here's what I have: Are you sure that code gets called? Are you loading from a nib? If the view comes from a nib you'll get screwy results overriding -loadView and you're probably better off with -viewDidLoad:.
|
# ? Jan 25, 2012 23:16 |
|
pokeyman posted:Are you sure that code gets called? Yeah just tested it by writing to the console within loadView, it's definitely being called but not actually doing anything regarding switching views. code:
code:
Should I just throw up all of my RootViewController and the view I'm trying to load's code? I really appreciate all of the help, I just feel so dumb and stuck right now.
|
# ? Jan 26, 2012 00:45 |
|
Yodzilla posted:Yeah just tested it by writing to the console within loadView, it's definitely being called but not actually doing anything regarding switching views. I know this isn't very helpful, but read Apple's View Controller Programming Guide. Doc Block fucked around with this message at 01:55 on Jan 26, 2012 |
# ? Jan 26, 2012 01:51 |
|
pokeyman posted:This is almost certainly not what you want to do, but the runtime can tell you whether a property takes a primitive or an object. Take a look at the Objective-C Runtime Programming Guide, in the Declared Properties section. You can get a type string (aka what you get out of @encode) for a property, which you would then have to parse for the information you're looking for. That is what I was looking for originally, thank you.
|
# ? Jan 26, 2012 02:00 |
|
I'm subclassing an IKImageView, and I can't go -setOverlay:forType: during awakeFromNib, it appears to be too early. Fails with: 2012-01-26 02:13:22.865 Test[4071:1203] *** could not add '<CALayer: 0x101b38f20>' linkedTo 'kIKImageLayerType' Works fine if I do it slightly delayed like this: [self performSelector:@selector(setupOverlays) withObject:nil afterDelay:0.0f]; But that is such a giant hack. Any suggestions?
|
# ? Jan 26, 2012 02:18 |
|
Doc Block posted:I know this isn't very helpful, but read Apple's View Controller Programming Guide. Yeah I've been through it but I guess whatever I needed didn't click. It doesn't help that I only work in iOS every six months or so and I didn't write this app to begin with. I get the feeling that I need to set the view I want as default to the view delegate programmatically and before the page even loads but I'm just not sure how to go about doing that.
|
# ? Jan 26, 2012 02:37 |
|
Yodzilla posted:I get the feeling that I need to set the view I want as default to the view delegate programmatically and before the page even loads but I'm just not sure how to go about doing that. Set the UIViewController's view property?
|
# ? Jan 26, 2012 03:02 |
|
Carthag posted:I'm subclassing an IKImageView, and I can't go -setOverlay:forType: during awakeFromNib, it appears to be too early. Fails with: For what it's worth, that's not actually slightly delayed so much as it'll happen on the next available iteration of the runloop. So it's more like a giant's little brother of a hack. I'm curious whether the issue is waiting for the IKImageView to appear before dicking with its layer. If you make an IKImageView with code and then immediately add the layer do you get the same problem? Either way, you could try subclassing some NSView method like -viewWillDraw and add your layer there?
|
# ? Jan 26, 2012 03:10 |
|
Yeah I know it's not terrible, I just need to read up on the life cycles of NSViews more I think. I tried googling, and I don't see a lot of people talking about that error, and those who do have conflicting solutions. Anyway here's what I've spent the evening doing: https://github.com/mikkelee/MEOverlayView Basically you can set an overlayDelegate on an IKImageView and it'll show overlays as you specify in the delegate, including moving them around, adding/deleting, all the while telling the delegate what it's doing. Still some work to be done, and cleanup, but it works well enough for an initial commit. Edit: Ignore the "update" button, that just jacks directly into "setupOverlays" and isn't really needed at the moment. Carthag Tuek fucked around with this message at 03:35 on Jan 26, 2012 |
# ? Jan 26, 2012 03:23 |
|
Not exactly on topic, but why does your screenshot have pinstripes?
|
# ? Jan 26, 2012 04:46 |
|
I guess this is how Lion looks now? I haven't done anything to the window itself. Actually the Finder windows look like that too now that I look at them. I don't notice them day-to-day to be honest so I dunno if that is how they always look. Anyway, I just realized that I need a good way for the delegate to let the view know that it has new info. I guess I'll have to look into notifications for that.
|
# ? Jan 26, 2012 05:04 |
|
If I want to show a view controller programmatically, do I have to define and implement my own init? I have created the view in interface builder, and would like to use it exactly how it is designed there. Should I just create an outlet in every class that is going to use it? Am I doing this completely the wrong way?
|
# ? Jan 26, 2012 05:09 |
|
Forgive a simple question (it's a long thread), but what should I put in the business/organization form when registering a personal Apple Developer account? Also, should I make a seperate Apple ID for my coding account? Can you release iOS software under a different name than your Apple ID?
|
# ? Jan 26, 2012 05:51 |
|
BiohazrD posted:If I want to show a view controller programmatically, do I have to define and implement my own init? I have created the view in interface builder, and would like to use it exactly how it is designed there. Should I just create an outlet in every class that is going to use it? Am I doing this completely the wrong way? You can just do MyViewController *vc = [[MyViewController alloc] init], which should work if the nib name is the same as the viewcontroller. Otherwise you can use initWithNibName:bundle:, like this MyViewController *vc = [[MyViewController alloc] initWithNibName:@"whatever.nib" bundle:nil] What exactly are you trying to do?
|
# ? Jan 26, 2012 07:31 |
|
BiohazrD posted:If I want to show a view controller programmatically, do I have to define and implement my own init? I have created the view in interface builder, and would like to use it exactly how it is designed there. Should I just create an outlet in every class that is going to use it? Am I doing this completely the wrong way? Where's the view in Interface Builder (or I guess it's just Xcode) right now? 10 If the view's in its own nib, set the 'File's Owner' of the nib to be an instance of your view controller class (in the Identity inspector, set the class). Then hook up the File's Owner's -view outlet to the UIView in the nib. Now you can simply code:
If the view's not in its own nib, consider putting it in its own nib then GOTO 10. If that's not an option, things get trickier. If you are only going to use the view once, you can add an outlet to whatever object in the nib is going to show the view, hook the view up to that outlet, then you can code:
|
# ? Jan 26, 2012 07:35 |
|
Analytic Engine posted:Forgive a simple question (it's a long thread), but what should I put in the business/organization form when registering a personal Apple Developer account? Also, should I make a seperate Apple ID for my coding account? Can you release iOS software under a different name than your Apple ID? The business/organization form field is what shows up in the App Store as "for sale by". Lots of individuals use their own name, or perhaps the name of their incorporated company if they have one. As far as I know you can put whatever you want in this field, but I could very well be wrong here as I've never tried anything fancy. I don't see any real benefit to have a separate Apple ID just for App Store use. If you find it convenient to keep them separate, go for it.
|
# ? Jan 26, 2012 07:39 |
|
pokeyman posted:
This is sort of what I did. I'm really, really new to XCode/ObjC so could you tell me how I create a NIB? I'm using storyboards, so I don't think they are created normally. Also, I think I probably made this harder to understand because I said "Interface Builder", sorry. I ended up using initWithIdentifier, which let's me just set an identifier for the view controller in the storyboard, and then create an instance of it as designed in my classes.
|
# ? Jan 26, 2012 15:42 |
|
Lumpy posted:Core Data Question: Well F-me, I just accidentally refreshed and lost a huge reply I wrote up... but basically they tell you how to do this in the article you linked. You just need to identify what your key field(s) are... in their example, they are using employeeID. The fact that the DB results and server results are both sorted in order allows you to use two indexes with a loop and walk forward, increasing the db list index only if the matching record is found in the server list, otherwise add a new record to the context and continue with the next pass until you reach the end of the server list. You just need to compare the dates as you go. If you can provide more detail I might be able to offer more help. You can also check out http://restkit.org/. I haven't used it yet but it is supposed to be able to grab stuff from a REST web service and stuff it into CoreData (using it as an offline cache and updating as appropriate).
|
# ? Jan 26, 2012 17:39 |
|
My OverlayView is nearing the point where I'm satisfied with it: https://github.com/mikkelee/MEOverlayView Anyone want to give it a spin and see if it works properly for them? Also ideas for features/bug reports are welcome.
|
# ? Jan 26, 2012 18:58 |
|
BiohazrD posted:This is sort of what I did. I'm really, really new to XCode/ObjC so could you tell me how I create a NIB? I'm using storyboards, so I don't think they are created normally. Also, I think I probably made this harder to understand because I said "Interface Builder", sorry. I haven't touched storyboards at all, so I'm just as lost. Sorry. If nobody else can help I'll poke around and see what I can do in the next couple days.
|
# ? Jan 26, 2012 20:23 |
|
|
# ? Jun 5, 2024 06:15 |
|
Yeah I have a feeling that storyboards are the way they're really trying to lead people into creating basic user interfaces. I think I might need to rewrite this app I'm currently working on to use them.
|
# ? Jan 26, 2012 20:25 |