Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 9, 2006, 07:59 AM   #1
Soulstorm
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
NSMatrix simple question

I am trying to create a calculator in Cocoa. So far, I have the parser ready (made in C++) but my problem lies into building the interface. This is a screenshot of my interface so far (very primitive).


All I want to do is to press a button and have its name appeared into the NSTextField. I could do that by making 10 different functions for each button, but I thought that an NSMatrix would help, so these 10 buttons you see are all NSMatrix.

My question is: How do I take the value of each button pressed in the NSMatrix so that I can display it into the textfield?
(of course there are many ways to do it... but I want to know the way which is more flexible).
Attached Images
 

Last edited by Soulstorm; Sep 9, 2006 at 08:05 AM.
Soulstorm is offline   0 Reply With Quote
Old Sep 9, 2006, 08:20 AM   #2
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Am I creating a memory leak here?

I think I made it, but I think that I am creating a memory leak. Can you check the function that updates the nstextfield? Am I creating a memory leak there?
Attached Files
File Type: zip Calculator test 1.zip (71.2 KB, 46 views)
Soulstorm is offline   0 Reply With Quote
Old Sep 9, 2006, 12:54 PM   #3
kpua
macrumors 6502
 
Join Date: Jul 2006
As far as memory leaks go, you're fine. For reference, here's the line you're referring to:

Code:
[theText setStringValue:[[theText stringValue] stringByAppendingString:[[theMatrix selectedCell] title]]];
You're not using alloc or copy anywhere, so there's no need to use release. All of the strings you're using here are autoreleased or managed by other objects.
kpua is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
NSMatrix simple binding question Monaj Mac Programming 1 Jun 16, 2011 08:32 AM
Ultrasnow | Simple question looking for simple answer :) xpsm1730 Jailbreaks and iOS Hacks 8 Jun 25, 2009 04:25 AM
simple question simple fix (Probably) shotgunfool iPod touch Hacks 2 Nov 11, 2007 12:37 PM
Simple question...hopefully simple answer downingp Mac Basics and Help 6 Dec 8, 2006 10:27 PM
Simple question for a simple mind J.C. Mac Help/Tips 6 May 12, 2002 08:34 AM


All times are GMT -5. The time now is 06:16 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC