Michael Beck | 1 Jan 2005 21:14
Picon

[newbie question] Any Gotchas with activating checkbox?

Hello,

I am working on a project that involves using a checkbox on a window.  I 
believe that I have connected the checkbox correctly (Connecting the 
outlet to the button and connecting the action to an IBAction)

when I use the [checbox state] message,  I get no response.  I have had 
some reaction where checking and unchecking the box creates a proper 
response, but when I change things it breaks and no reaction occurs again.

Any hints?  I can put my project in a tarball and send it to you  if 
that would help.

Thanks
Mike Beck
Ian Joyner | 2 Jan 2005 12:44
Picon
Favicon

Re: Unobvious coding error in C

On 30/12/2004, at 7:37 AM, M. Carlson wrote:

> On Wednesday, December 29, 2004, at 04:47  PM, Timothy J. Wood wrote:
>> On Monday, December 27, 2004, at 04:47  PM, Alex Majora wrote:
>>>    for (j=0;j<5,k<100;j++,k++) {
>>   You should probably log a bug against the compiler here if it 
>> didn't emit a warning (or, you should turn on all possible -W flags 
>> and -Werror).  The "," operator should warn, I think, if its first 
>> argument can be known to have no side effects.
>
> Um, can somebody explain to us newbies why the j<5 has no effect?

Because C is a very badly designed language with lots of these kinds of 
gotchas, which should not be in any widely used language in the 21st 
century. C is the underlying reason why today's operating systems, 
especially windows are so flaky. Fortunately for OS X, Unix has 
undergone more trial by fire.

> Why does only the last part "k<100" have an effect on the loop?

Because that's how C defines it... silly isn't it! Both C and C++ seem 
to go to great lengths to make any syntax permissible by resort to all 
kinds of crazy sematics. Hence the chronic state of the programming 
profession today. C is the Windows of programming languages – bad 
design gone crazy, propped up by a virtual monopoly.
Markus Hitter | 2 Jan 2005 13:57
Picon

Re: [newbie question] Any Gotchas with activating checkbox?


Am 01.01.2005 um 21:14 schrieb Michael Beck:

> I believe that I have connected the checkbox correctly (Connecting the 
> outlet to the button and connecting the action to an IBAction)

One of the advantages of Cocoa is, you can simply ask the object behind 
your outlet what type it is:

     NSLog( <at> "I am % <at> ", myOutlet);

where "% <at> " will be substituted with the answer to a [myOutlet 
description].

Similar things can be done in the debugger console.

HTH,
Markus

- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/
Markus Ruggiero | 2 Jan 2005 15:04
Picon

Window will close not called

Hi,

I have a situation where I must react to my window being closed to do 
some cleanup.
The window is created normally from a NIB and the AppController is the 
file's owner. The file's owner is also set as delegate for the window. 
The app controller implements  windowWillClose. However the method is 
only called when I quit the application (I have some debug NSLog output 
that shows this) but not when I close the window (either with command-w 
or with the mouse). Seems that I am missing something here, question is 
"what"?

This is on Panther 10.3.7 with XCode 1.5

Thanks and a happy new year to you all
---markus---

Markus Ruggiero
rucotec consulting and technologies    		email     
mailto:markus@...
rucotec GmbH                                			web       
http://www.rucotec.ch
Steinentorstrasse 8
4051 Basel                                  				Mobile    +41 (0)79 508 
4701
Switzerland                                 				Phone/Fax +41 (0)61 271 
4990
elijah wright | 2 Jan 2005 16:17

Re: Unobvious coding error in C


> Because that's how C defines it... silly isn't it! Both C and C++ seem 
> to go to great lengths to make any syntax permissible by resort to all 
> kinds of crazy sematics. Hence the chronic state of the programming 
> profession today. C is the Windows of programming languages  bad design 
> gone crazy, propped up by a virtual monopoly.

C is actually a great language, and extremely powerful for systems work. 
Remember, though, that C is ~35 years old and predates the *invention* of 
object-oriented methodologies and most other "modern" syntactical 
constructs.

Don't blame the language for the bad behavior of programmers or 
corporations - that just makes you look like a crank and a bit of a loser.

--elijah
Jeffrey T. Read | 2 Jan 2005 16:56

Re: Unobvious coding error in C


On Jan 2, 2005, at 10:17 AM, elijah wright wrote:
> C is actually a great language, and extremely powerful for systems 
> work. Remember, though, that C is ~35 years old and predates the 
> *invention* of object-oriented methodologies and most other "modern" 
> syntactical constructs.
>

For what it does, C is great, and it has the added benefit that it's 
really easy to pick up. C++, on the other hand, is a tremendous bodge 
and when working in it I find myself using only a small subset of its 
capabilities (akin to "C with classes" from the 80s).

C and OOP were actually invented within a couple of years of each other 
(and here I am referring to Smalltalk, the first language to be called 
"object oriented"). If you want to loosen your definitions a little, 
OOP actually predates C (Simula, Sketchpad).

What happens is, management at large corporations picks ONE programming 
style and insists that all its programmers adhere to it. This was 
structured/procedural programming in the 80s and meant that the bulk of 
development work was done in C or Pascal or something like that.

When C++ became mature, "object oriented programming" became a 
buzzword, and corporate management switched to object-oriented design 
as the de facto gold standard for software design. Of course, NeXT got 
the jump on just about everybody in the late 80s with its Objective-C 
API and toolkit. :)

Great programmers understand all of these design ideas: structured, OO, 
(Continue reading)

Markus Hitter | 2 Jan 2005 17:38
Picon

Re: Window will close not called


Am 02.01.2005 um 15:04 schrieb Markus Ruggiero:

> The app controller implements  windowWillClose. However the method is 
> only called when I quit the application

Is the "Release when close" box in Interface Builder checked for this 
window?

"One-shot" would be an candidate to try as well.

Markus

- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/
Bob Ippolito | 2 Jan 2005 17:58
Gravatar

Re: Unobvious coding error in C

On Jan 2, 2005, at 10:17 AM, elijah wright wrote:

>
>> Because that's how C defines it... silly isn't it! Both C and C++ 
>> seem to go to great lengths to make any syntax permissible by resort 
>> to all kinds of crazy sematics. Hence the chronic state of the 
>> programming profession today. C is the Windows of programming 
>> languages  bad design gone crazy, propped up by a virtual monopoly.
>
> C is actually a great language, and extremely powerful for systems 
> work. Remember, though, that C is ~35 years old and predates the 
> *invention* of object-oriented methodologies and most other "modern" 
> syntactical constructs.
>
> Don't blame the language for the bad behavior of programmers or 
> corporations - that just makes you look like a crank and a bit of a 
> loser.

The point was that the language is full of dangerous ambiguities that 
don't belong.  This has nothing to do with whether it's object oriented 
or not.  Pascal doesn't really let you do idiotic things quite as 
readily as C does, for example (not that I particularly like Pascal).

Yes, if used properly, you don't often run into these problems with C.  
However, C gives you enough rope to hang yourself and the reason to do 
it.

-bob
Eric Morand | 2 Jan 2005 18:46
Picon

NSObjectController not releasing its content ?

Hi to all !

I'm currently on the process to optimize my application (memory leaks 
and all) and I have found something that looks weird to me : it seems 
that NSObjectController instances (when instantiated in IB) don't 
release their content when the NIB is closed.

Look at this Test application (not compiled Xcode project) :

http://cceric.chez.tiscali.fr/Test.zip

When the window is closed, the AppController is sent a release message. 
But it is never released because its retain count is set to 3 ! If I 
unplug the "content" outlet from the NSObjectController in IB, the 
retain count is to 1 and the AppController is released.

I just don't get whet I'm doing wrong. I suppose this has something to 
do with the fact that the NSObjectController should be released when 
the window is closed...but I don't know how to do this and WHY I should 
have to do this by myself : aren't IB objects supposed to be released 
automatically ?

Can someone help me on this ?

Oh, and by the way : HAPPY NEW YEAR to everyone ! And thanks for your 
valuable help all along the past year !!! :o)

Eric.
Ken Anderson | 2 Jan 2005 19:07

Re: NSObjectController not releasing its content ?

Eric,

Any objects that are in the 'Instances' section of your nib are your 
responsibility to release.  The are brought into the world with a 
retain count of 1.  Therefore, you should at least of outlets from your 
controller to all these objects so you can release them.

One item that has bit people for a long time is:

IB will call your setXXX: method if you have one to set outlets in your 
controller (or any other object).  If you retain that object inside the 
set method, you now have 2 retains to release.  So, if you have this:

- (void) setOutlet:(id) obj
{
	[outlet autorelease];
	outlet = [obj retain];
}

and 'outlet' is an object in the Instances section of your nib file, 
you'll need this:

- (void) dealloc
{
	[outlet release];
	[outlet release];
	[super dealloc];
}

Ken
(Continue reading)


Gmane