Re: View shifted up on iPhone simulator
Hmm I have a few comments: It look like you're seeing the superposition of two problems that look like one: 1) The status bar is covering up the very top of your view in the sim 2) The bottom button is 20px further from the bottom in the sim The interface builder likes to make views default to a height of 460, not 480. I always change mine to 480 before I start using them. From your pictures, it looks like this is the culprit - that, and the status bar covering up the top. In order to change it, you must disable the 'simulate status bar' option in the view's inspector. I believe that view is designed to be shown in a view controller who takes the status bar into account already. I also believe that you simply added the view as a subview of the window, which is what caused the status bar to cover up the top. (also, the interface builder shows you what the view would look like in a view controller that takes the status bar into account) From this, you have a few options: 1) Disable the status bar in your application, set the view's Simulated Interface Elements to not show the status bar, then change the hight of the view to 480. To disable the status bar in your application, go to its info.plist, add a new row, scroll to the bottom, select Status Bar is Initially Hidden and set it to TRUE. 2) Use a view controller to show your view. I didn't fully understand just what the controllers did until after a very long time of tinkering, but they're a godsend... or, an apple-send in this case. They'll help making stuff like that line up, though only after you understand them. or 3) Use both the above options (this is my recommendation) On 2 Oct 2009, at 12:28 PM, Anthony Smith wrote: When I run my app in the iPhone simulator the view seems to be shifted up on the screen. If that doesn't make sense I've uploaded some images. Take a look and see if you've run into this before. http://projects.sticksnleaves.com/iphonedev/ib.png http://projects.sticksnleaves.com/iphonedev/sim.png Thanks!___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/kd7qis%40gmail.com This email sent to kd7...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
CAKeyframeAnimation for 'position' not working
(Note: I apologize for not having this nicely formatted. My previous message - 8kB over the size limit - was rejected because it was too large, so I had to remove the extra HTML) I have a CAKeyframeAnimation that simply will not work. I have a layer. When I apply a CABasicAnimation to it, it animated exactly as expected. When I apply the keyframe animation, it doesn't... Here's the code for the keyframe animation: + (CAAnimation*) randomPathAnimationWithBounds:(CGRect)inBounds keyFrames:(UInt32)inKeys layer:(CALayer*)inLayer duration:(CGFloat) duration { // Setup our variables for keeping track of points and relative timings CGPoint points[inKeys] ; CGFloat timing[inKeys+1] ; timing[inKeys] = CKRandomRange(1000) ; // CKRandomRange(range) is the same as random()%range CGFloat total = timing[inKeys] ; // Keep a running tally of our total int count for later normalization // This will produce a random point putting the layer somewhere outside the parent's bounds, supplied to us as bounds CGPoint r1 = [self randomPointForLayer:inLayer outOfBounds:inBounds] ; inLayer.position = r1 ; // apply the initial position // Make our arrays NSMutableArray * locArr = [NSMutableArray arrayWithCapacity:inKeys+1] ; NSMutableArray * timArr = [NSMutableArray arrayWithCapacity:inKeys+1] ; UInt32 i ; for ( i=0 ; iinKeys ; i++ ) { // Get timing timing[i] = CKRandomRange(1000) ; // Make a new random relative timing total += timing[i] ; // add it to the running tally // Get some random point inside the bounds points[i] = CGPointMake ( CKRandomRange(inBounds.size.width) +inBounds.origin.x , CKRandomRange(inBounds.size.height) +inBounds.origin.y ) ; // Add that point to the location array [ locArr addObject: [NSValue valueWithCGPoint:points[i]] ] ; } // Get an endpoint, outside the bounds, and add it to the array CGPoint r2 = [self randomPointForLayer:inLayer outOfBounds:inBounds] ; [locArr addObject:[NSValue valueWithCGPoint:r2]] ; // Normalize the timings, comulative timing[0] = timing[0] / total * duration ; for ( i=1 ; iinKeys+1 ; i++ ) timing[i] = timing[i] / total * duration + timing[i-1] ; // Fill the timing value array for ( i=0 ; iinKeys+1 ; i++ ) [timArr addObject:[NSNumber numberWithFloat:timing[i]]] ; // Make the animation CAKeyframeAnimation * animation = [CAKeyframeAnimation animationWithKeyPath:@position] ; animation.values = locArr ; animation.duration = duration ; animation.calculationMode = kCAAnimationLinear ; animation.keyTimes = timArr ; animation.fillMode = kCAFillModeForwards ; // Print stuff NSLog ( @%@ , animation ) ; NSLog ( @ -- %lu, %lu , locArr.count , timArr.count ) ; NSLog ( @ -- %@ , animation.keyTimes ) ; NSLog ( @ -- %@ , animation.values ) ; return animation ; } The output, from the print statements, to show that it has VALID values, is: 2009-10-01 13:11:00.887 Whose Line[56132:207] CAKeyframeAnimation: 0x3921510 2009-10-01 13:11:00.888 Whose Line[56132:207] -- 11, 11 2009-10-01 13:11:00.888 Whose Line[56132:207] -- ( 0.178501, 0.4809336, 0.5841551, 0.8514135, 0.9723865, 1.163051, 1.258054, 1.540105, 1.850756, 1.916502, 2 ) 2009-10-01 13:11:00.888 Whose Line[56132:207] -- ( NSPoint: {437, 159}, NSPoint: {30, 0}, NSPoint: {446, 272}, NSPoint: {398, 21}, NSPoint: {469, 117}, NSPoint: {377, 111}, NSPoint: {84, 95}, NSPoint: {101, 111}, NSPoint: {291, 138}, NSPoint: {359, 237}, NSPoint: {7, -12} ) The timings look right - the duration was set to 2 seconds... So they're all in order and randomly spaced. The positions are also all inside the bounds (iPhone landscape, full screen @ 480x320) However, when I add the animation, nothing happens... Any ideas would be greatly appreciated! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
CARenderer Example
Hi all, I've been trying to make a class to record CALayers and their animations to QuickTime movies. I've only found two ways to do this: Poll and renderInContext I can have a timer running at some rate, and I use that to tell the layer's presentationLayer renderInContext:(someBitmapContext). This does not work with CAShapeLayer or any other OpenGL layer. Use CARenderer This should work for what I need, but I don't know anything about OpenGL and need to have this recorder object by... tomorrow... Does anyone know of - or could anyone create - a very simple example of efficiently doing the following:? • Creating an OpenGL offscreen context; • Create the CARenderer, setup for the context; (loop, or something:) • Drawing animations to the context, while • Capturing context as a bitmap, and • Writing image to quicktime file; then, • Clean up I've been searching for this for about four days now and have turned up very little. All of Apple's docs [that I've found] on OpenGL assume that I am already an experienced OpenGL programmer, which I am not. I really don't care about OpenGL right now, I just need to record this layer. I would greatly appreciate any help anyone could provide!___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
CALayer renderInContext not rendering all sublayers
Hi all, I've been unable to find anything on this through Google searches... I'm building for x86_64 on Snow Leopard. I have a window containing a view whose layer has two sublayers, set up like this: - (void)awakeFromNib { [self setWantsLayer:YES] ; points = [ [CALayer layer] retain ] ; bindings= [ [CALayer layer] retain ] ; [self.layer addSublayer:bindings] ; [self.layer addSublayer:points] ; } Later, I add sublayers (sent via NSNotificationCenter) like this: if ( [object isMemberOfClass:[TSBinding class]] ) { [self.bindings addSublayer:object] ; } else { [self.points addSublayer:object] ; } Some time later, just after (also tried just before) the animations start, I do this: recorder = [CARecorder recorderWithLayer:self.layer destination:path duration:[GSVariable cgfloatForKey:@Duration] frameRate:15. delegate:self] ; CARecorder is a class I made which spawns a thread and, at a regular interval, tells the given layer's presentationLayer to render in a local context, using the following code: [self.layer.presentationLayer renderInContext:self.context]; (Note that the CARecorder has iVars layer and context that are set during initialization. 'layer' corresponds to the layer sent to it in initialization. Also note that it is not a problem of the context being over-written repeatedly, as putting the context creation in the thread's loop instead of initialization doesn't change anything) However, when it draws, it only draws the top CALayer who's a subclass of the main layer. I recorded, using CaptureMe.app, the view as displayed on screen. I put that video, the video produced by the code as well as the CARecorder code online here: http://www.kd7qis.com/CARecorder_Help Please take a look. I'd greatly appreciate any help anyone could provide on how to get this to draw/record/save both sublayers of this layer... - Christopher ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
CAShapeLayer for Drawing Lines; Animations Skewed
Hi all, In my current development project, I have numerous dots that will be moved around periodically, each connected by a line. The dots are represented as CALayers, with the contents set to a simple 20x20 dot, and they are moved around by animating the position property. The connecting lines will be drawn between the centers of two dots, and will be moved via an animations whenever the dots change position. This is where I'm running into trouble. Any suggestions on how to fix what I've done so far or suggestions for a different, easier approach are more than welcome. What I've tried: CALayer with 50x1 Square as Contents In this method, I used a 50x1 square. For every animation, I set the bounds to: CGRectMake ( 0 , 0 , absoluteDistanceBetweenPoints , 1 ) ; and the transform to CATransform3DMakeRotation ( angleBetweenPoints , 0 , 0 , 1 ) ; This worked, but had the unfortunate side-effect of, during some of the moves, rotating too far around in the wrong direction, making the endpoints come out from under the points. (For example, instead of rotating 90º, it would rotate 270º in the wrong direction. This, in theory, is easy to fix, but isn't as easy as it sounds. CAShapeLayer with Path from PointA to PointB In this method, I used a CAShapeLayer with the correct color and a 1px width. I made a path between the two points. For moves, I created another path representing the new position and used a CABasicAnimation to animate the path property. This also 'works,' but also has a side-effect: A line, instead of animating from (oldPointA,oldPointB) to (newPointA,newPointB) would animate to (oldPointA,oldPointB) to (randomPoint,randomPoint) to (newPointA,newPointB) (Note: (aPoint,bPoint) represents a line/ path from aPoint to bPoint) Any suggestions for improving these methods (especially fixing the CAShapeLayer, which would be optimal) would be greatly appreciated! Thanks, -Christopher___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
QuickTime Animation Rendering
Hi all, I have a project where I will be drawing nothing more than simple circles with lines connecting them. At some point, I will be animating these lines and circles to move them to another position. I would like to: (1) Display these, animated, on the screen; and (2) Render the animation to a QuickTime file. As far as the lines themselves go, a multi-layered CALayer (using CALayer's -addSublayer method) would work perfectly for viewing on the screen... but I don't know how to export this to QT. So, I have two questions: (1) Is there a way for me to create the animations with CoreAnimation Layers (CALayer and sublayers) and simply tell some object to write to file? If so, how? (2) What is another method to create the animation easily? I would prefer that the same code be used to both display on screen and render to file; but it would also be acceptable to write to file then play the file on screen. Note that I am going more for simplicity of code rather than speed performance, as the on-screen viewing will ONLY be for 'previewing' the output. All publications of the animations will be in the form of a QuickTime video. -Christopher Kemsley Sent from my Beautiful 17 MacBook Pro ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Design Paterns: +/- Initializers and Subclassing (Solved)
Oh yeah - I thought I did that once and it didn't work... Though, now that I think about it, I think I did it the other way in the past (used self in a +method to refer to a newly created object) So, in all reality, the +method could be boiled down to: [self.new autorelease] ; since self.new = MyClass.new = [MyClass new] = [ [self alloc] init ] Thanks for clearing that up! On Aug 2, 2009, at 10:34 PM, Quincey Morris wrote: On Aug 2, 2009, at 22:26, Quincey Morris wrote: return [ [ [[self class] alloc] init ] autorelease ] ; ('self' refers to the class object because this is a class method) Doh, if that's true, then: return [ [ [self alloc] init ] autorelease ] ; should be good enough. (IIRC, [self class] == self when self is a class, but I always confuse myself with the class versions of methods, sorry.) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/kd7qis%40gmail.com This email sent to kd7...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Design Paterns: +/- Initializers and Subclassing
Ok, so here's the deal: I have a class (CYMethod) that provides a standard interface for multiple implementations of the same type (multiple ways in which to read a file, for instance). Here are its constructors: + (CYMethod*) method { return [ [ [CYMethod alloc] init ] autorelease ] ; } - (CYMethod*) init { if ( self = [super init] ) { } return self ; } What I want to be able to do is subclass this, but only override the - init method. However, if I use the above code and call [CYMethodSubclass method] I'll get back a new instance of CYMethod, not CYMethodSubclass. How do I make the +method call return an initialized object of whatever type the +method was sent to? (so that [CYMethodSubclass method] returns [ [ [CYMethodSubclass alloc] init ] autorelease]) Thanks, -Christopher ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Looking for a method to Lock and Unlock the computer
Hi all, I'm looking to write a program to run in the background and do the following: • Listen for Event A • If Event A occurs, either Sleep Display or Display Login Screen • Listen for Event B • If Event B occurs, log-in to a specific account Listening for the event is not a problem. However, what is a problem is logging in and displaying the login screen progmatically. My preference is to display the login screen, though simply sleeping the display would suffice if I cannot have the former. I'd appreciate any suggestions anyone might have. Thanks, Christopher___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSSocketPort initRemoteWithTCPPort is never valid
This is just a quick question for anyone who may know (or, at least I hope it's quick) If I declare a port: port = [ [NSSocketPort alloc] initRemoteWithTCPPort:portNumber host:hostName ] ; And use it with an NSConnection, it works. If I use that same port in any other way (such as NSFileHandle) it doesn't work. The error it gives is: [NSConcreteFileHandle writeData:]: Bad file descriptor (when I use initWithFileDescriptor:port.socket ) However, if I create a port like this: port = [ [NSSocketPort alloc] initWithTCPPort:portNumber ] ; (and add it to the port manager, run loops, etc of course) NSFileHandle suddenly works (as a server) Ideally, I'd like to be able to use NSFileHandle (or something very similar) on both ends of the connection. Any thoughts/suggestions? Finding anything useful for what I'm trying to do online has proven to be almost completely futile... - Christopher ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Networking
I'm not sure how to begin this, so I'll start off with what I have. What I have: Device A and Device B. Device A is connected to the internet (at address The Address, and has port The Port routed to it for instance) Device B is also connected to the internet, but is not on the same local network as Device A. What I want: A custom written server on Device A that listens on The Port for a device to connect. It expects to be sent an NSData object and will be expected to return another NSData object. Device B should be able to, through a blocking method (or background in a thread), get an NSData object returned by Device A after giving it another NSData object. (for example, Device B asks Device A Do I have messages? and gets Yes, you have two in response) What I've tried and/or cannot use: I cannot use Distributed Objects. Although this would make this incredibly easy, Device B is an iPhone and does not support distributed objects. I've tried setting up an HTTP server using NSSocketPort and NSFileHandle's acceptConnectionInBackgroundAndNotify method; however, I seem to be unable to get the client (regardless of platform) to be able to send an arbitrary data package to it and get one in return. So, my question is, does anybody know of any other ways - or good beginner's guides - to networking in situations like this? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSString's mutableCopy creating a leak?
I'm writing a program that, in one table view, has the following code: id receivedName = [theDatabase itemAtIndex:editedRow] ; editedRowName = [receivedName mutableCopy] ; [receivedName release]; where editedRowName is defined as an NSMutableString. [theDatabase itemAtIndex:editedRow] Asks my database to return item editedRow. The object at that index is an NSString. For this function, the database would return [theStringHere retain] My code needs a mutable version of this string, so I make a mutableCopy of it and release the old one, as to prevent a memory leak. However, when I do a Run with performance tool: Leaks, it tells me that, ever time this part of the code runs, it leaks a GeneralBlock-32 with the following information: Category: CFString (store) Event Type: Malloc Responsible Library: Foundation Responsible Caller: -[NSCFString mutableCopyWithZone:] Does anybody know where this leak is coming from? This is an Objective-C/Cocoa based application, compiling for the iPhone Simulator with the i386 architecture. (Before anybody yells at me saying that the iPhone SDK cannot be discussed here, read this: http://developer.apple.com/iphone/program/ ) -Christopher Kemsley Sent from my Beautiful 17 MacBook Pro ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSString's mutableCopy creating a leak?
Instead of replying to everybody individually, let me say this: I neglected to mention in my original post that, when this object is deallocated, it explicitly deallocated the editedRowName before calling a [super dealloc], so the thing should be deallocated. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSString's mutableCopy creating a leak?
A bit more information about what's going on: The object is a subclass of UIViewController. When I click on something in a UITableView, it allocates this object and initializes it to use as an editor. Example: You're looking at a list of stuff, and you click on one of the object to bring up an editor pane. The list you're looking at allocates the object, which then sets the editedRowName. On initialization, I set editedRowName to the mutableCopy. Later, when I pop the view controller, the navigtionController deallocates the object (and I have verified this). In the deallocation, it used to call [editedRowName dealloc]. Only once is editedRowName set to anything - in the initialization stage. Later, the only modification is [editedRowName setString:], but this does not cause a memory leak. I was not aware that I shouldn't explicitly call a dealloc... Why not? Replacing it with a release in the object made that leak go away, but I still don't understand why I can't dealloc it. I. Savant, thank you for your comments on the NDA - they were exactly right. I believe you all have answered my main question though, and that is that I should use only release/retain statements - not dealloc statements. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSTableView problems when 0 items
I have an NSTableView object and an NSPopUpButton that I use to select a category of information to display in the table... The problem is this: If I select a category with 0 items in it, the table view will update as expected... but, if I select one with more than one item right afterwards, the entire list does not display right away. Instead, it updates row by row when I select it. I AM sending it a [nameOfTable reloadData] message, and it IS getting that information it needs to be getting... but I cannot figure out why it's doing this! To see what I mean, click here: http://www.gooblidood.com/temp/weird.mp4 Anyone have any idea how to fix this stupid problem? Any help would be greatly appreciated! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSTextField setStringValue method - deallocates?
I'm new to Obj-C, and I'm trying to make sure I start off writing good code so I don't have to come back and learn how to avoid dirty code and/or memory leaks. That being said, if I do the following: NSString *someString = [ NSString stringWithString:@Hello World! ] ; [ someNSTextField setStringValue:someString ] ; Does the NSTextField take care of de-allocating the memory from the old value by itself? -Christopher Kemsley J-Net Webcasting http://www.jnetcast.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]