Re: Packages vs bundles vs folders etc

2009-05-11 Thread Peter Ammon


On May 10, 2009, at 10:43 PM, Chris Idou wrote:



 Would it be fair to say that if a path is a directory, and if the  
kMDItemContentType != public.folder then  
NSWorkspace.isFilePackageAtPath would

return YES?

No.  A non-package directory may not even conform to  
public.folder.  For example, volume mount points have the type ID  
public.volume, which does
conform; but frameworks have the type ID public.framework, which  
does not conform.


But isn't a framework a package, thus making my statement correct?  
If a framework is not a package, then what specifically makes a  
package a package that a framework doesn't fit?




Frameworks are not packages.  A package is a directory that is  
presented as a single file to the user, but frameworks are shown as  
folders and are browsable like other folders.


You can check the UTI hierarchy in the UTCoreTypes.h header (try open - 
h UTCoreTypes.h).


Perhaps I should state my question more explicitly. I'm trying to  
figure out what things should be copied atomically. When a directory  
is really a bundle (is a bundle == package?), then it must be  
considered as one unit. If it's just a folder, then the files  
therein have their own unique reasons for existing. But I'm  not  
sure which API exactly will give me the distinction I want to make.



If you copy two folders, Finder reports the total number of items  
contained within them; but if you copy two applications, Finder  
reports only two items.  Is that the sort of distinction you want to  
make?


If so, I think you're on the right track.  On Leopard, I would get the  
UTI of a file via -[NSWorkspace typeOfFile: error:], and then see if  
it conforms to kUTTypeFolder via -[NSWorkspace type:fileType  
conformsToType:(NSString *)kUTTypeFolder].  If it does NOT conform, it  
should be treated as a single item.


If you need Tiger compatibility, you can do the same thing, except you  
would use LaunchServices functions like LSCopyItemAttribute().


-Peter

___

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: converting a characer to a keycode

2009-05-11 Thread Jean-Daniel Dupas


Le 9 mai 09 à 22:29, kvic...@pobox.com a écrit :


At 9:14 PM -0700 5/8/09, glgue...@amug.org wrote:

ken wrote:

the only way i can think to perform this conversion is to  
itereate  over the virtual key codes 0-127 (with various  
combinations of  shift and option keys) until i find the one that  
matches the user  input character.


and while this is certainly doable, it feels awfully clumsy (and   
potentially slow).


is there a better way?



Create the inverse mapping once, e.g. in an NSDictionary, then use  
that mapping thereafter, instead of searching repeatedly.


This assumes there is an unambiguous inverse mapping, which ain't  
necessarily so.  For example, a keyboard with a numpad has  
duplicate key legends for all numpad keys.  I think these numpad  
keys have different keycodes than the keys in the main alphanum  
layout.  So given a character like 1 (or *, =, etc.) it's not  
possible to

reverse it to a single unique keycode.


greg,
thanx for the reply. and yes i am aware of the possible duplicates.  
i was just hoping for a better way other that iterating via  
UCKeyTranslate (which turns out to be fast enough, so probably no  
need to cache via a dictionary or otherwise).


An alternative would be to parse the UCHR resource yourself instead of  
using UCKeyTranslate.


http://developer.apple.com/documentation/Carbon/reference/Unicode_Utilities_Ref/uu_app_uchr/uu_app_uchr.html


___

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: Subject: detect option key on startup

2009-05-11 Thread Jean-Daniel Dupas

Try in - applicationDidFinishLaunching:


Le 10 mai 09 à 00:58, Mitchell Livingston a écrit :

In what method would that need to be in to get the key on startup? I  
tried without luck in init and awakeFromNib.


On Saturday, May 09, 2009, at 06:48PM, Kirk Kerekes kirkkere...@gmail.com 
 wrote:


How About:	([[NSApp currentEvent] modifierFlags]   
NSAlternateKeyMask)






___

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/devlists%40shadowlab.org

This email sent to devli...@shadowlab.org



___

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: Help debugging bindings issues

2009-05-11 Thread Alexander Spohr


Am 08.05.2009 um 18:44 schrieb Alex Smith:

[ addObserver:forKeyPath:options:context:] is not supported. Key  
path: personName


Please post the complete line. This looks like something is missing.

Are you sure you entered the right path in IB?

atze

___

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: NSTask temrinationStatus always == 1?

2009-05-11 Thread marc hoffman

Jim,

i have an odd issue with NSTask. for some reason, no matter what  
result code
my executable returns (im running xcodebuild, if that matters),  
NSTask's
terminationStatus always reports back as 1. if instead i use  
system() to run
the exact same command, i get bak proper error codes (0 for  
success., other

non-zero, non-one values for real failures.

anyone have any ideas what could be going wrong to cause this?


You'll have to show your code. NSTask correctly returns the exit code
(see below).


got it: i had been staring at this for hours, but when i pasted it  
here, it jumped at m right away: i accidentally passed the executable  
name as first item in the argument array. what threw me off is that  
according tot he console output, it seems that xcodebuild (which  
happens to be what i was running) does the build just fine, so i could  
not easily yell it was failing, compared to running it with system() -  
the output looked (close to) identical, down to the final BULD  
SCUCCEEDED.


ftr, the code i was using is this. passing in the appropriate subarray  
of params fixed it. so thanx!



NSArray *split = [command componentsSeparatedByString:@ ];

	NSMutableArray *params = [NSMutableArray arrayWithCapacity:[split  
count]];

for (NSString *s in split)
{
		s = [s stringByTrimmingCharactersInSet:[NSCharacterSet  
whitespaceCharacterSet]];

if ([s length]  0) [params addObject:s];
}

NSTask *t = [[[NSTask alloc] init] autorelease];
[t setLaunchPath:[split objectAtIndex:0]];
[t setArguments:params]; // oops. first element should not be here!
[t setStandardOutput:[NSPipe pipe]];

[t launch];
NSFileHandle *stdOut = [[t standardOutput] fileHandleForReading];
NSMutableData *outputData = nil;

while ([t isRunning])
{
NSData *d = [stdOut availableData];
if (d)
{
if (outputData) [outputData appendData:d];
else outputData = [[d mutableCopy] autorelease];
}
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]];
}

if (outputData)
{
		NSString *s = [[[NSString alloc] initWithData:outputData  
encoding:NSUTF8StringEncoding] autorelease];

[output setArray:[s componentsSeparatedByString:@\n]];
}

[t waitUntilExit];
int result = [t terminationStatus];
	//int result = system([command  
cStringUsingEncoding:NSUTF8StringEncoding]);

if (result)
{
		self.error = [NSString stringWithFormat:@Execution of \%...@\ failed  
with error code %d., [split objectAtIndex:0], result];

return NO;
}
return YES;


thanx,
marc
___

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: NSString to bit pattern

2009-05-11 Thread erappy
Thanks Alastair, it was a good hint and help.Cheers,


On Sat, May 9, 2009 at 4:51 AM, Alastair Houghton 
alast...@alastairs-place.net wrote:

 On 8 May 2009, at 10:00, erappy wrote:

  Hi, I am trying to find  way to convert the NSString object into its bit
 pattern and convert that bit pattern into another NSString object,
 For Example if I have
 NSString *origStr = @Hello:
 NSString * bitPatternoforigStr ;
 no I want to convert it to the bit pattern if Hello and return an object
 of
 type NSString with bit pattern.
 it should be something like;
 bitPatternoforigStr = @01011010011000100100110101100101 ;
 Can someone help me in this.


 You need to start by deciding what encoding you wish to use for your
 string.  NSString, broadly speaking, works as if it is a container for
 UTF-16 code units.  It isn't always implemented that way under the covers,
 but you can assume that it behaves that way.  If UTF-16 is what you need,
 you could simply iterate over the string in a loop doing something like
 this:

  NSUInteger len = [myString length];
  for (NSUInteger n = 0; n  len; ++n) {
unichar ch = [myString characterAtIndex:n];

// Turn ch (which is 16 bits in length) into binary and append it to
 your result string
  }

 Often you might not want UTF-16 though, and in that case you can use
 NSString's -dataUsingEncoding: method to convert the string to an NSData
 containing data in the desired encoding.  Then you might loop over it
 differently, e.g.

  #include inttypes.h

  ...

  NSData *stringData = [myString dataUsingEncoding:NSUTF8StringEncoding];
  NSUInteger dataLen = [stringData length];
  const uint8_t *bytes = (const uint8_t *)[stringData bytes];

  for (NSUInteger n = 0; n  dataLen; ++n) {
// Turn bytes[n] into binary and append it to your result string
  }

 Converting an integer into a binary string is a trivial programming
 exercise, so you should be able to do that part on your own.

 Kind regards,

 Alastair.

 --
 http://alastairs-place.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 arch...@mail-archive.com


Re: Packages vs bundles vs folders etc

2009-05-11 Thread Chris Idou


I'm surprised that frameworks act like folders in Finder, yet don't conform to 
public.folder.

To be more explicit, I'm writing some code that synchronises two folders. If 
directory A contains file X and directory B contains file Y, then synchronising 
them depends on what kind of directory it is. If it is a package, then a 
resulting package containing files X and Y would be wrong, it could be a 
corrupt package. Folders should be synchronised and have both X and Y. But I'm 
not sure about frameworks being neither a folder nor a package. What would 
users expect?

Hmm, I see that bundle, package and folder are the three decendents of 
public.directory. framework conforms to bundle rather than package and appears 
in the finder like a folder. However applications descend from bundle and do 
NOT appear like folders.

Why does finder decide that frameworks appear like folders?

And which items does spotlight indexing delve into? Which items would iDisk 
synchronise atomically?




From: Peter Ammon pam...@apple.com
To: Chris Idou idou...@yahoo.com
Cc: cocoa-dev@lists.apple.com
Sent: Monday, 11 May, 2009 4:02:17 PM
Subject: Re: Packages vs bundles vs folders etc



On May 10, 2009, at 10:43 PM, Chris Idou wrote:


 Would it be fair to say that if a path is a directory, and if the 
 kMDItemContentType != public.folder then NSWorkspace.isFilePackageAtPath 
 would 
return YES?


No.  A non-package directory may not even conform to public.folder.  For 
example, volume mount points have the type ID public.volume, which does 
conform; but frameworks have the type ID public.framework, which does not 
conform.

But isn't a framework a package, thus making my statement correct? If a 
framework is not a package, then what specifically makes a package a package 
that a framework doesn't fit?


Frameworks are not packages.  A package is a directory that is presented as a 
single file to the user, but frameworks are shown as folders and are browsable 
like other folders.

You can check the UTI hierarchy in the UTCoreTypes.h header (try open -h 
UTCoreTypes.h).

Perhaps I should state my question more explicitly. I'm trying to figure out 
what things should be copied atomically. When a directory is really a bundle 
(is a bundle == package?), then it must be considered as one unit. If it's just 
a folder, then the files therein have their own unique reasons for existing. 
But I'm  not sure which API exactly will give me the distinction I want to make.

If you copy two folders, Finder reports the total number of items contained 
within them; but if you copy two applications, Finder reports only two items.  
Is that the sort of distinction you want to make?

If so, I think you're on the right track.  On Leopard, I would get the UTI of a 
file via -[NSWorkspace typeOfFile: error:], and then see if it conforms to 
kUTTypeFolder via -[NSWorkspace type:fileType conformsToType:(NSString 
*)kUTTypeFolder].  If it does NOT conform, it should be treated as a single 
item.

If you need Tiger compatibility, you can do the same thing, except you would 
use LaunchServices functions like LSCopyItemAttribute().

-Peter




___

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: Packages vs bundles vs folders etc

2009-05-11 Thread Peter Ammon
Frameworks act like folders so that users can browse their header  
files in Finder.  As a developer, I think I would want that frameworks  
be treated atomically for synchronization purposes.


My understanding is that Finder decides that frameworks are user  
browsable because they're directories, but not packages.  Applications  
are not user browsable because they descend from com.apple.package.   
The bundle type says something about how the directory's contents are  
arranged; the package type says something about how it should be  
presented to the user.  You can have either, both, or neither.


Unfortunately I don't know the details of Spotlight or iDisk  
synchronization with respect to these types.


On May 11, 2009, at 5:11 AM, Chris Idou wrote:



I'm surprised that frameworks act like folders in Finder, yet don't  
conform to public.folder.


To be more explicit, I'm writing some code that synchronises two  
folders. If directory A contains file X and directory B contains  
file Y, then synchronising them depends on what kind of directory it  
is. If it is a package, then a resulting package containing files X  
and Y would be wrong, it could be a corrupt package. Folders should  
be synchronised and have both X and Y. But I'm not sure about  
frameworks being neither a folder nor a package. What would users  
expect?


Hmm, I see that bundle, package and folder are the three decendents  
of public.directory. framework conforms to bundle rather than  
package and appears in the finder like a folder. However  
applications descend from bundle and do NOT appear like folders.


Why does finder decide that frameworks appear like folders?

And which items does spotlight indexing delve into? Which items  
would iDisk synchronise atomically?


From: Peter Ammon pam...@apple.com
To: Chris Idou idou...@yahoo.com
Cc: cocoa-dev@lists.apple.com
Sent: Monday, 11 May, 2009 4:02:17 PM
Subject: Re: Packages vs bundles vs folders etc


On May 10, 2009, at 10:43 PM, Chris Idou wrote:



 Would it be fair to say that if a path is a directory, and if  
the kMDItemContentType != public.folder then  
NSWorkspace.isFilePackageAtPath would

return YES?

No.  A non-package directory may not even conform to  
public.folder.  For example, volume mount points have the type ID  
public.volume, which does
conform; but frameworks have the type ID public.framework, which  
does not conform.


But isn't a framework a package, thus making my statement correct?  
If a framework is not a package, then what specifically makes a  
package a package that a framework doesn't fit?




Frameworks are not packages.  A package is a directory that is  
presented as a single file to the user, but frameworks are shown as  
folders and are browsable like other folders.


You can check the UTI hierarchy in the UTCoreTypes.h header (try  
open -h UTCoreTypes.h).


Perhaps I should state my question more explicitly. I'm trying to  
figure out what things should be copied atomically. When a  
directory is really a bundle (is a bundle == package?), then it  
must be considered as one unit. If it's just a folder, then the  
files therein have their own unique reasons for existing. But I'm   
not sure which API exactly will give me the distinction I want to  
make.



If you copy two folders, Finder reports the total number of items  
contained within them; but if you copy two applications, Finder  
reports only two items.  Is that the sort of distinction you want to  
make?


If so, I think you're on the right track.  On Leopard, I would get  
the UTI of a file via -[NSWorkspace typeOfFile: error:], and then  
see if it conforms to kUTTypeFolder via -[NSWorkspace type:fileType  
conformsToType:(NSString *)kUTTypeFolder].  If it does NOT conform,  
it should be treated as a single item.


If you need Tiger compatibility, you can do the same thing, except  
you would use LaunchServices functions like LSCopyItemAttribute().


-Peter


Chat right from the comfort of your inbox. Show me how..


___

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: Packages vs bundles vs folders etc

2009-05-11 Thread Alastair Houghton

On 11 May 2009, at 13:42, Peter Ammon wrote:

My understanding is that Finder decides that frameworks are user  
browsable because they're directories, but not packages.   
Applications are not user browsable because they descend from  
com.apple.package.  The bundle type says something about how the  
directory's contents are arranged; the package type says something  
about how it should be presented to the user.  You can have either,  
both, or neither.


I'm not sure whether this is now classed as legacy behaviour, but on  
HFS+ at least, Finder looks at the bundle bit to determine whether  
something is treated as a bundle or just an ordinary folder.


You can see this if you use /Developer/Tools/SetFile to set the bundle  
bit for a folder (e.g. /Developer/Tools/SetFile -a B MyFolder).


Kind regards,

Alastair.

--
http://alastairs-place.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 arch...@mail-archive.com


Re: [iPhone] UITableViewController headache

2009-05-11 Thread Matthew Mashyna

On May 11, 2009, at 12:20 AM, James Lin wrote:


Hi all,

This is strange, i don't know what to make of it.

I have a view with a TableView in it.

If i use UITableViewController class, which is supposed to be the  
correct class to use,
the tableview (which has 1 UILabel and 1 UITextField combined cells)  
is only correctly rendered up to cell 7.
starting with 8 to 10 (which are off-screen to begin with) won't  
render correctly when scrolled into view.


With my limited experience, trouble shooting this one is a headache.

So what do i do?

I changed the UITableViewController to UIViewController.

AND?

Problem solved! ALL 1 to 10 TableViewCells renders beautifully!

BUT, i am not using the correct class...

Any suggestions?

James
___


UITableViewController is mostly a convenience class that stubs the  
required protocol for UITableView when you create a new subclass using  
Xcode. It doesn't really matter what controller class you use if you  
implement the protocol and set the delegate and data source.


Your observation makes complete sense if you have a view with a  
tableview and other views with it. A UITableViewController assumes  
that 'view' is a table view and you can't put other views in it other  
than programatically filling it with cells via the data source  
methods. Making it a UIViewController instead and connecting the  
tableview's delegate and data source will make it behave properly.


Matt
___

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: Renaming a file repositions icon in Finder

2009-05-11 Thread Jim Turner
On Fri, May 8, 2009 at 5:45 PM, Sean McBride s...@rogue-research.com wrote:
 On 5/8/09 2:52 PM, Jim Turner said:

It appears that renaming a file will cause the Finder to reposition
the icon for the file if it's currently displayed in a icon view
somewhere.  Is there any way to prevent that from happening?  It looks
very strange to have icons jump all over the place just because of a
rename.

Thinking that it might have been the method with which I was renaming
the file, I tried NSFileManager's moveItemAtPath:toPath:error:,
rename(), and FSRenameUnicode() and all three exhibit the same
problem.

 Many apps exibit this problem and it has driven me and others nuts for
 years.  Do file a(nother) bug.

 --
 
 Sean McBride, B. Eng                 s...@rogue-research.com
 Rogue Research                        www.rogue-research.com
 Mac Software Developer              Montréal, Québec, Canada




If anyone would like to me-too my me-too, it's rdar://problem/6874498

-- 
Jim
http://nukethemfromorbit.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


Re: Help debugging bindings issues

2009-05-11 Thread Alex Smith

Here is the full error listing.

2009-05-11 08:22:55.043 RaiseMan[2935:10b] [NSCFArray 0x158f90  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
personName
2009-05-11 08:22:55.062 RaiseMan[2935:10b] [NSCFArray 0x16efb0  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
personName
2009-05-11 08:22:55.067 RaiseMan[2935:10b] [NSCFArray 0x158f90  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
expectedRaise
2009-05-11 08:23:02.160 RaiseMan[2935:10b] [NSCFArray 0x16efb0  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
expectedRaise


I am not using an IBOutlet or IBAction for two reasons. 1) The author  
did not use them is his example (nor are they in his project code) and  
2) I am binding personName and expectedRaise to the table columns. So  
Table Column binding is set to bind to Array Controler, Controller Key  
= Arranged Objects, model key path = personName. (same for  
expectedRaise).


Thanks,
Alex


On May 11, 2009, at 2:19 AM, Alexander Spohr wrote:



Am 08.05.2009 um 18:44 schrieb Alex Smith:

[ addObserver:forKeyPath:options:context:] is not supported. Key  
path: personName


Please post the complete line. This looks like something is missing.

Are you sure you entered the right path in IB?

atze



___

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: [iPhone] UITableViewController headache

2009-05-11 Thread Alex Curylo


On 11-May-09, at 6:21 AM, cocoa-dev-requ...@lists.apple.com wrote:


UITableViewController is mostly a convenience class that stubs the
required protocol for UITableView when you create a new subclass using
Xcode. It doesn't really matter what controller class you use if you
implement the protocol and set the delegate and data source


Oh, there's other stuff that UITableViewController works out for you  
as well.


For starters, Apple will reject your application (at least, it  
rejected one of mine) if it doesn't disable an existing selection when  
shown. UITableView sorts that for you instead of having to check  
yourself.


Less trivially, if you want to edit some text in a cell at the bottom  
of the screen, UITableView will magically make the text field scroll  
up above the keyboard and put itself away afterwards. Sorting that out  
yourself to look good manually takes a bit of work.


And so forth. So it does behoove you to use it if appropriate. Now, if  
I could just get it to handle a background image nicely...


--
Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/

When I met you, it was a little like meeting Jubal from _Stranger In A
 Strange Land_. I *think* that's a compliment... -- Dominique



___

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: Help debugging bindings issues

2009-05-11 Thread Alexander Spohr

The docs for NSArray say:

Special Considerations
NSArray objects are not observable, so this method raises an exception  
when invoked on an NSArray object. Instead of observing an array,  
observe the to-many relationship for which the array is the collection  
of related objects.


It looks like your bindings are wrong (bound to an NSArray) somewhere.
Go to IB and recheck your bindings.

atze



Am 11.05.2009 um 16:43 schrieb Alex Smith:


Here is the full error listing.

2009-05-11 08:22:55.043 RaiseMan[2935:10b] [NSCFArray 0x158f90  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
personName
2009-05-11 08:22:55.062 RaiseMan[2935:10b] [NSCFArray 0x16efb0  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
personName
2009-05-11 08:22:55.067 RaiseMan[2935:10b] [NSCFArray 0x158f90  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
expectedRaise
2009-05-11 08:23:02.160 RaiseMan[2935:10b] [NSCFArray 0x16efb0  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
expectedRaise


I am not using an IBOutlet or IBAction for two reasons. 1) The  
author did not use them is his example (nor are they in his project  
code) and 2) I am binding personName and expectedRaise to the table  
columns. So Table Column binding is set to bind to Array Controler,  
Controller Key = Arranged Objects, model key path = personName.  
(same for expectedRaise).


Thanks,
Alex


On May 11, 2009, at 2:19 AM, Alexander Spohr wrote:



Am 08.05.2009 um 18:44 schrieb Alex Smith:

[ addObserver:forKeyPath:options:context:] is not supported. Key  
path: personName


Please post the complete line. This looks like something is missing.

Are you sure you entered the right path in IB?

atze





___

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: Help debugging bindings issues

2009-05-11 Thread Quincey Morris

On May 11, 2009, at 07:43, Alex Smith wrote:


Here is the full error listing.

2009-05-11 08:22:55.043 RaiseMan[2935:10b] [NSCFArray 0x158f90  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
personName
2009-05-11 08:22:55.062 RaiseMan[2935:10b] [NSCFArray 0x16efb0  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
personName
2009-05-11 08:22:55.067 RaiseMan[2935:10b] [NSCFArray 0x158f90  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
expectedRaise
2009-05-11 08:23:02.160 RaiseMan[2935:10b] [NSCFArray 0x16efb0  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
expectedRaise


I am not using an IBOutlet or IBAction for two reasons. 1) The  
author did not use them is his example (nor are they in his project  
code) and 2) I am binding personName and expectedRaise to the table  
columns.


Actually, the terminology works the other way round. You're binding  
the table columns to [something that gives you access to properties]  
personName and expectedRaise.


So Table Column binding is set to bind to Array Controler,  
Controller Key = Arranged Objects, model key path = personName.  
(same for expectedRaise).


That's perfectly fine. Note that the table column is actually bound to  
ArrayController.arrangedObjects -- that is to an array property of the  
ArrayController. For a specific row, the table view fetches the  
corresponding [non-array] object of that array, and extracts the  
desired properties (personName and expectedRaise) from that [non- 
array] object. Although we typically say that the column is bound to  
ArrayController.arrangedObjects.personName, that isn't literally true  
because that's not a valid key path. (And that's why controller key  
and model key are separate in the binding.)


This suggests that your problem is not the table column binding, but  
the ArrayController's content binding (or its content connection, if  
you're not using bindings there). According to the error message, the  
ArrayController's content is an array of arrays instead of an array of  
Person objects.



___

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: converting a characer to a keycode

2009-05-11 Thread kvic...@pobox.com

At 9:27 AM +0200 5/11/09, Jean-Daniel Dupas wrote:

Le 9 mai 09 à 22:29, kvic...@pobox.com a écrit :


At 9:14 PM -0700 5/8/09, glgue...@amug.org wrote:

ken wrote:

the only way i can think to perform this 
conversion is to itereate  over the virtual 
key codes 0-127 (with various combinations of 
shift and option keys) until i find the one 
that matches the user  input character.


and while this is certainly doable, it feels awfully clumsy (and
potentially slow).

is there a better way?



Create the inverse mapping once, e.g. in an 
NSDictionary, then use that mapping 
thereafter, instead of searching repeatedly.


This assumes there is an unambiguous inverse 
mapping, which ain't necessarily so.  For 
example, a keyboard with a numpad has 
duplicate key legends for all numpad keys.  I 
think these numpad keys have different 
keycodes than the keys in the main alphanum 
layout.  So given a character like 1 (or 
*, =, etc.) it's not possible to

reverse it to a single unique keycode.


greg,
thanx for the reply. and yes i am aware of the 
possible duplicates. i was just hoping for a 
better way other that iterating via 
UCKeyTranslate (which turns out to be fast 
enough, so probably no need to cache via a 
dictionary or otherwise).


An alternative would be to parse the UCHR 
resource yourself instead of using 
UCKeyTranslate.


http://developer.apple.com/documentation/Carbon/reference/Unicode_Utilities_Ref/uu_app_uchr/uu_app_uchr.html


i actually thought about doing that... but since 
it was easiest to just use UCKeyTranslate (i had 
pre-existing code i could easily copy, paste, 
modify) to get my surrounding code working, i 
went with that initially with the intent to 
explore other solutions if performance was an 
issue. performance wasn't/isn't an issue, so i've 
left the simple approach in.


thanx for the suggestion.

ken
___

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


Creating NSAttributedString objects using WebKit in secondary thread

2009-05-11 Thread Dragan Milić

Hello all,

Is there any way to initialise and use WebKit out of the main thread?  
I know this message may look like good candidate for the Webkit-dev  
mailing list, but I actually don't want to use WebKit directly, it's  
just a consequence of trying to create NSAttributedString instance  
from data in memory. Here is the longer story...


I need to create NSAttributedString objects and draw them onto the  
NSImage object (which holds the current graphic context). The  
attributed strings are created from data in memory buffer and since it  
is not know at the time of creation what kind of data the buffer  
holds, I use -[NSAttributedString  
initWithData:options:documentAttributes:error:] method, which examines  
the data and loads it using whatever format it seems to contain. Now,  
according to the documentation:


In Mac OS X v10.3, the options key @UseWebKit specifies that WebKit- 
based HTML importing be used (and must be specified for the other  
options to be recognised). In Mac OS X v10.4 and later, WebKit is  
always used for HTML documents, and all of the options except  
@UseWebKit are recognised (attribute identifiers are available on  
Mac OS X v10.4 and later; use actual string value keys for Mac OS X  
v10.3).


Since the application in question supports Tiger and above, the WebKit  
is always used. The problem is that string creation and drawing needs  
to be executed in the secondary thread and then the WebKit complains  
whenever the data in the buffer contains a HTML/XML document.


Sometimes an exception Cannot use WebKit in secondary thread is  
thrown, and sometimes only a warning about threading violation is  
printed out onto the console (with remark that it would be printed  
only once) and creation of HTML-based attributed strings works, but is  
very crash-prone. In any case, operation is far from being reliable.


Is there any way to solve this without jumping into the main thread  
for strings creation?


Thanks in advance,
Milke
___

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: Creating NSAttributedString objects using WebKit in secondary thread

2009-05-11 Thread Douglas Davidson


On May 11, 2009, at 10:53 AM, Dragan Milić wrote:


Is there any way to initialise and use WebKit out of the main thread?


No, there isn't.  This is a fundamental restriction on the use of  
WebKit.


Douglas Davidson



___

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: Packages vs bundles vs folders etc

2009-05-11 Thread Sean McBride
On 5/11/09 1:55 PM, Alastair Houghton said:

 My understanding is that Finder decides that frameworks are user
 browsable because they're directories, but not packages.
 Applications are not user browsable because they descend from
 com.apple.package.  The bundle type says something about how the
 directory's contents are arranged; the package type says something
 about how it should be presented to the user.  You can have either,
 both, or neither.

I'm not sure whether this is now classed as legacy behaviour, but on
HFS+ at least, Finder looks at the bundle bit to determine whether
something is treated as a bundle or just an ordinary folder.

Are you sure the Finder consults the bundle bit?  I would think that
it's Launch Services doing that.

Also, I don't think the bundle bit is 'legacy'.  On the contrary, I
think people should be setting it when appropriate (ex: package type
documents like .xcodeproj).  If they don't, then computers that don't
have the application installed will see such documents as folders.  ex:
on a machine without Xcode, browse a file server and find
some .xcodeproj documents, they will be shown as folders because Xcode
fails to set the bundle bit.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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: Packages vs bundles vs folders etc

2009-05-11 Thread Dave Carrigan


On May 11, 2009, at 11:08 AM, Sean McBride wrote:


Are you sure the Finder consults the bundle bit?  I would think that
it's Launch Services doing that.



Yes, it does:

 mkdir -p /tmp/foo/bar/bat
 SetFile -a B /tmp/foo
 open /tmp

Note that finder thinks foo is a single item, not a folder.

If you do

 SetFile -a b /tmp/foo

and go back to your finder window, it will look like a folder again.

--
Dave Carrigan
d...@rudedog.org
Seattle, WA, USA



PGP.sig
Description: This is a digitally signed message part
___

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: Packages vs bundles vs folders etc

2009-05-11 Thread Sean McBride
On 5/11/09 11:47 AM, Dave Carrigan said:

 Are you sure the Finder consults the bundle bit?  I would think that
 it's Launch Services doing that.


Yes, it does:

  mkdir -p /tmp/foo/bar/bat
  SetFile -a B /tmp/foo
  open /tmp

Note that finder thinks foo is a single item, not a folder.

If you do

  SetFile -a b /tmp/foo

and go back to your finder window, it will look like a folder again.

Yes yes, but is the Finder doing that itself, or is it asking LS?
Certainly the bundle bit is consulted, but at which layer?  Anyway,
doesn't matter much.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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


NSFileHandleDataAvailableNotification problems

2009-05-11 Thread Todd Heberlein

Hi all,

I have a problem reading periodic data from a file descriptor, and I  
am wondering if I am using the methods wrong. The basic code is below,  
but essentially I


	(1) register my object to be called when an  
NSFileHandleDataAvailableNotification is sent to the notification  
center;


	(2) create an NSFileHandle for the file descriptor and send it the  
waitForDataInBackgroundAndNotify method;


	(3) in the callback method, I read the data and then call  
waitForDataInBackgroundAndNotify again so it can look for new data.


The callback method will be called sometimes just once but often  
several times until eventually I get a EXC_BAD_ACCESS signal.


Is there something glaringly wrong with my code? Should I not call  
waitForDataInBackgroundAndNotify in the callback function? Does  
reading from the file descriptor via read() instead of through the  
NSFileHandle cause problems?


Any suggestions would be appreciated,

Todd

// Register callback method when data is available
[nc addObserver:self
selector:@selector(dataAvailable:)
name:NSFileHandleDataAvailableNotification
object:nil];

// Use an NSFileHandle for the file descriptor
myFileHandle = [[NSFileHandle alloc] initWithFileDescriptor:fd];
[myFileHandle waitForDataInBackgroundAndNotify];


- (void) dataAvailable: (NSNotification*)notification
{
// read data directly from the fd
[myFileHandle waitForDataInBackgroundAndNotify];
}

___

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: Packages vs bundles vs folders etc

2009-05-11 Thread Alastair Houghton
On 11 May 2009, at 19:08, Sean McBride s...@rogue-research.com  
wrote:



On 5/11/09 1:55 PM, Alastair Houghton said:



I'm not sure whether this is now classed as legacy behaviour, but on
HFS+ at least, Finder looks at the bundle bit to determine whether
something is treated as a bundle or just an ordinary folder.


Are you sure the Finder consults the bundle bit?  I would think that
it's Launch Services doing that.


Well I don't know, to be honest. I've always assumed it's Finder that  
checks, but maybe it is LS.



Also, I don't think the bundle bit is 'legacy'.


I should explain what I meant a bit better. My point was more that the  
bundle bit is HFS specific, so like the type and creator codes, while  
it's good to set it, I'm not sure anything should be relying on it.



 On the contrary, I
think people should be setting it when appropriate


Agreed.

Kind regards,

Alastair

--
http://alastairs-place.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 arch...@mail-archive.com


[iPhone] UITableView with state?

2009-05-11 Thread Eric E. Dolecki
I am using my own graphics for a tableview's cell background and selected
background (grouped tableview). I am using UILabels added to the
contentView, so I'm not setting the cell text directly at all. I have tagged
the labels (3 in each cell) so I can get to them later within the selection
callback method.


I can easily get the current section and row. However I'd like to be able to
get the previous selected cell to be able to reset it's UI. What do I mean?
The selected cell background is dark so I need to switch the texts to white
from black. But this means I need to reset the previous cells labels to
black again.


What's a good way to do this? Does that information come along for the ride
on the callback method for cell selection? Do I need to reset the cells
somehow and then change the text colors? It seems I have to implement some
sort of state to have this happen, or else there is an approved established
way to so this already.


Thanks,

Eric
___

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: Attr Str drawing vs Layout Manager drawing

2009-05-11 Thread Martin Wierschin
You can release the text container because the layout manager  
retains it,
and you can release the layout manager because the text storage  
object

retains it.


It's fine as long as you don't continue to use the objects directly.
The sample code amounts to this:

id obj1 = [Bar new], obj2 = [Bar new];
[obj1 setFoo:obj2]
[obj2 release];  // All well and good.

[obj2 bazWithQuux:YES];  // NO!  We don't own obj2 anymore.


Yes, but the documentation is telling you that obj1 retains obj2,  
so in that case you are assured obj2 is still valid. Of course,  
there is the possibility for something crazy like:


static void XXCodeYouDontControlOrForgotYouWrote( NSTextStorage* ts )
{
NSLayoutManager* lm = [[ts layoutManagers] objectAtIndex:0];
[ts removeLayoutManager:lm];
[ts addLayoutManager:[[[NSLayoutManager alloc] init] autorelease]];
}

{
NSTextStorage* ts = [[NSTextStorage alloc] init];   
NSLayoutManager* lm = [[NSLayoutManager alloc] init];
[ts addLayoutManager:ts];
[lm release];

XXCodeYouDontControlOrForgotYouWrote( ts );
[lm numberOfGlyphs]; // probably crash
}

So technically you're correct, but maybe paranoid :P

~Martin

___

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: [iPhone] UITableView with state?

2009-05-11 Thread Luke the Hiesterman
First of all, it's generally discouraged as a UI design to allow cells  
to stay selected. That is, inside your  
tableView:didSelectRowAtIndexPath: method, you should call [tableView  
deselectRowAtIndexPath:indexPath animated:YES] so that you get the  
nice animated highlight fade-away that people expect in an iPhone app.  
If, for some reason, you feel you need to keep the cell selected, it  
seems simple enough to keep around a reference to the last selected  
cell. Then, inside your tableView:didSelectRowAtIndexPath: method you  
could perform whatever changes you need to format the coloring of the  
formerly selected cell back to normal, and finally set your reference  
to the cell that has just been selected.


Luke


On May 11, 2009, at 2:16 PM, Eric E. Dolecki wrote:

I am using my own graphics for a tableview's cell background and  
selected

background (grouped tableview). I am using UILabels added to the
contentView, so I'm not setting the cell text directly at all. I  
have tagged
the labels (3 in each cell) so I can get to them later within the  
selection

callback method.


I can easily get the current section and row. However I'd like to be  
able to
get the previous selected cell to be able to reset it's UI. What do  
I mean?
The selected cell background is dark so I need to switch the texts  
to white
from black. But this means I need to reset the previous cells labels  
to

black again.


What's a good way to do this? Does that information come along for  
the ride
on the callback method for cell selection? Do I need to reset the  
cells
somehow and then change the text colors? It seems I have to  
implement some
sort of state to have this happen, or else there is an approved  
established

way to so this already.


Thanks,

Eric
___

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/luketheh%40apple.com

This email sent to luket...@apple.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


Re: Creating NSAttributedString objects using WebKit in secondary thread

2009-05-11 Thread Dragan Milić

On pon 11. 05. 2009., at 20:07, Douglas Davidson wrote:


On May 11, 2009, at 10:53 AM, Dragan Milić wrote:


Is there any way to initialise and use WebKit out of the main thread?


No, there isn't.  This is a fundamental restriction on the use of  
WebKit.


Yes, I know. I just hoped there was some secret magical workaround  
which would enable me to create attributed strings in the main thread.  
The point is I'm trying to create something like Finder's Show icon  
preview functionality, trying to create graphical representations of  
some text files (which are kept in memory) but to still keep UI  
responsive if a user wants to scroll view etc.


So, I assume creating attributed strings is not thread safe, but I  
don't remember anything like that stated in the documentation. In my  
opinion, that looks like a bug.


Milke___

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: Attr Str drawing vs Layout Manager drawing

2009-05-11 Thread Kyle Sluder
On Mon, May 11, 2009 at 5:32 PM, Martin Wierschin mar...@nisus.com wrote:
 So technically you're correct, but maybe paranoid :P

Seth and I discussed this off-list... it essentially amounts to this:

I tend to stick very much to the general rules, rather than saying
well I know that Foo is going to retain Bar when I call -setQuux:, so
I can just release it here.  The less one has to think about memory
management, the fewer memory management errors one creates.

--Kyle Sluder
___

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: Packages vs bundles vs folders etc

2009-05-11 Thread Mike Abdullah



Also, I don't think the bundle bit is 'legacy'.


I should explain what I meant a bit better. My point was more that  
the bundle bit is HFS specific, so like the type and creator codes,  
while it's good to set it, I'm not sure anything should be relying  
on it.


The main reason for setting it these days is for an occasion where a  
package-based document winds up on a Mac without your app installed.  
With the bundle bit set, although it has no proper icon, the document  
will at least appear in the Finder as a single file.

___

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: [iPhone] UITableView with state?

2009-05-11 Thread Eric E. Dolecki
Actually now that I think about it, I wouldn't really need to keep the cell
selected, as I plan on displaying another view at that time, so the initial
UI change itself will be okay... but how do I reset the view with the table
in it so that all the cell reset themselves? reloadData?
E

On Mon, May 11, 2009 at 5:48 PM, Luke the Hiesterman luket...@apple.comwrote:

 First of all, it's generally discouraged as a UI design to allow cells to
 stay selected. That is, inside your tableView:didSelectRowAtIndexPath:
 method, you should call [tableView deselectRowAtIndexPath:indexPath
 animated:YES] so that you get the nice animated highlight fade-away that
 people expect in an iPhone app. If, for some reason, you feel you need to
 keep the cell selected, it seems simple enough to keep around a reference to
 the last selected cell. Then, inside your tableView:didSelectRowAtIndexPath:
 method you could perform whatever changes you need to format the coloring of
 the formerly selected cell back to normal, and finally set your reference to
 the cell that has just been selected.

 Luke



 On May 11, 2009, at 2:16 PM, Eric E. Dolecki wrote:

  I am using my own graphics for a tableview's cell background and selected
 background (grouped tableview). I am using UILabels added to the
 contentView, so I'm not setting the cell text directly at all. I have
 tagged
 the labels (3 in each cell) so I can get to them later within the
 selection
 callback method.


 I can easily get the current section and row. However I'd like to be able
 to
 get the previous selected cell to be able to reset it's UI. What do I
 mean?
 The selected cell background is dark so I need to switch the texts to
 white
 from black. But this means I need to reset the previous cells labels to
 black again.


 What's a good way to do this? Does that information come along for the
 ride
 on the callback method for cell selection? Do I need to reset the cells
 somehow and then change the text colors? It seems I have to implement some
 sort of state to have this happen, or else there is an approved
 established
 way to so this already.


 Thanks,

 Eric
 ___

 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/luketheh%40apple.com

 This email sent to luket...@apple.com





-- 
http://ericd.net
Interactive design and development
___

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: Creating NSAttributedString objects using WebKit in secondary thread

2009-05-11 Thread Stephen J. Butler
2009/5/11 Dragan Milić mi...@mac.com:
 So, I assume creating attributed strings is not thread safe, but I don't
 remember anything like that stated in the documentation. In my opinion, that
 looks like a bug.

It is thread safe... if you stick to the Foundation methods. The
method you're trying to use, however, is part of the AppKit additions.
Hence the non-thread safeness.

One way to do this might be to spawn a helper app that accepts data
somehow (mach ports might be fastest using vm copy-on-write techniques
IIRC, but harder to implement), render on that process's main thread,
and then pass the data back (NSAttributedString supports NSCoding).

But then you're getting into all the caveats about background
processes, window server connections, and fast user switching.
However, in your case, if the background process dies for whatever
reason, who cares, right?
___

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: [iPhone] UITableView with state?

2009-05-11 Thread Luke the Hiesterman
reloadData is potentially fine. Presumably, though, you really only  
have one cell you need to reset (the one that was tapped to cause you  
to animate in another view), so all you need to do is reset that cell.  
Again, probably easy to keep around a reference to that cell, and you  
could do whatever resetting you require in viewDidAppear:.


Luke

On May 11, 2009, at 3:12 PM, Eric E. Dolecki wrote:

Actually now that I think about it, I wouldn't really need to keep  
the cell selected, as I plan on displaying another view at that  
time, so the initial UI change itself will be okay... but how do I  
reset the view with the table in it so that all the cell reset  
themselves? reloadData?


E

On Mon, May 11, 2009 at 5:48 PM, Luke the Hiesterman luket...@apple.com 
 wrote:
First of all, it's generally discouraged as a UI design to allow  
cells to stay selected. That is, inside your  
tableView:didSelectRowAtIndexPath: method, you should call  
[tableView deselectRowAtIndexPath:indexPath animated:YES] so that  
you get the nice animated highlight fade-away that people expect in  
an iPhone app. If, for some reason, you feel you need to keep the  
cell selected, it seems simple enough to keep around a reference to  
the last selected cell. Then, inside your  
tableView:didSelectRowAtIndexPath: method you could perform whatever  
changes you need to format the coloring of the formerly selected  
cell back to normal, and finally set your reference to the cell that  
has just been selected.


Luke



On May 11, 2009, at 2:16 PM, Eric E. Dolecki wrote:

I am using my own graphics for a tableview's cell background and  
selected

background (grouped tableview). I am using UILabels added to the
contentView, so I'm not setting the cell text directly at all. I  
have tagged
the labels (3 in each cell) so I can get to them later within the  
selection

callback method.


I can easily get the current section and row. However I'd like to be  
able to
get the previous selected cell to be able to reset it's UI. What do  
I mean?
The selected cell background is dark so I need to switch the texts  
to white
from black. But this means I need to reset the previous cells labels  
to

black again.


What's a good way to do this? Does that information come along for  
the ride
on the callback method for cell selection? Do I need to reset the  
cells
somehow and then change the text colors? It seems I have to  
implement some
sort of state to have this happen, or else there is an approved  
established

way to so this already.


Thanks,

Eric
___

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/luketheh%40apple.com

This email sent to luket...@apple.com




--
http://ericd.net
Interactive design and development


___

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: Listing running process

2009-05-11 Thread Ken Thomases

On May 9, 2009, at 1:29 PM, Arivan S. Bastos wrote:

How do I list the running processes of the operating system? And how  
get

info about that processes?


http://developer.apple.com/qa/qa2001/qa1123.html

Cheers,
Ken

___

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: NSFileHandleDataAvailableNotification problems

2009-05-11 Thread Ken Thomases

On May 11, 2009, at 2:35 PM, Todd Heberlein wrote:

I have a problem reading periodic data from a file descriptor, and I  
am wondering if I am using the methods wrong. The basic code is  
below, but essentially I


	(1) register my object to be called when an  
NSFileHandleDataAvailableNotification is sent to the notification  
center;


	(2) create an NSFileHandle for the file descriptor and send it the  
waitForDataInBackgroundAndNotify method;


Try reversing the order of the above two steps and observe the  
specific NSFileHandle object.  It's possible that there are other  
NSFileHandles out there (created by the framework?) and, as things  
stand, your method would be called whenever those post their  
notifications, too.


[...] Should I not call waitForDataInBackgroundAndNotify in the  
callback function?


Actually, you must if you want to be notified again.

Does reading from the file descriptor via read() instead of through  
the NSFileHandle cause problems?


It might.  Have you tried using -availableData instead?

Alternatively, have you tried using -readInBackgroundAndNotify and the  
NSFileHandleReadCompletionNotification, getting the data from the  
notification's userInfo?




Any suggestions would be appreciated,


Make sure all of your memory management is correct.  Retain the file  
handle object for as long as you need it to exist, etc.


Regards,
Ken

___

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: Packages vs bundles vs folders etc

2009-05-11 Thread Ken Thomases

On May 11, 2009, at 1:02 AM, Peter Ammon wrote:

If so, I think you're on the right track.  On Leopard, I would get  
the UTI of a file via -[NSWorkspace typeOfFile: error:], and then  
see if it conforms to kUTTypeFolder via -[NSWorkspace type:fileType  
conformsToType:(NSString *)kUTTypeFolder].  If it does NOT conform,  
it should be treated as a single item.


If you need Tiger compatibility, you can do the same thing, except  
you would use LaunchServices functions like LSCopyItemAttribute().


I know that UTIs are the new hot thing, but doesn't it seem most  
direct to consult the kLSItemInfoIsPackage bit of the flags field of  
the LSItemInfoRecord filled out by LSCopyItemInfoFor{Ref,URL}?


Regards,
Ken

___

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: NSToolbarItem with custom view in Interface Builder 3 (Leopard)

2009-05-11 Thread Jonathan Hess

Hey Gunnar -

You won't be able to make this work with an instance of custom view  
dragged from the library. Here are a couple of suggestions for  
workarounds:


You could add an outlet to the toolbar item you'd like to use a custom  
view with, and then place the custom view at the top level of your  
NIB, and also add an outlet to it. In awakeFromNib, you could call  
setView: on the toolbar item with the correct view.


Alternatively, you could use a view object that wasn't a custom view.  
Interface Builder doesn't provide a view object in the library that  
isn't a specific subclass or NSView, or a custom view, but you can get  
a hold of a plain NSView by copying and pasting one from someplace  
else. For example, copying a window's content view by using Interface  
Builder's outline view will get you a vanilla instance of NSView.  
Paste one into the top level of a document and resize it to a  
reasonable size, and and then you can drag it from the document window  
into the toolbar.


Good Luck -
Jon Hess

On May 9, 2009, at 11:36 AM, Gunnar Proppe wrote:



I followed the steps described here to set up a toolbar item with a  
custom view in Interface Builder:

http://developer.apple.com/documentation/Cocoa/Conceptual/Toolbars/Articles/ToolbarInIB.html

Unfortunately my custom view's drawRect is never called. I verified  
that it does get initialized. The toolbar item's min and max size  
are set up properly. Just to be safe I had my view conform to  
NSCoding but initWithCoder and ecodeWithCoder aren't called. I tried  
various springs and struts settings with no results.


Digging deeper, I subclassed NSToolbarItem and overrode setView and  
setMinSize so I could break on them. setMinSize is getting called  
with the correct values. Interestingly, setView gets called before  
my custom view is initialized. I assume this is the proxy NSView  
object. Then my custom view is initialized (initWithFrame) but the  
NSToolbarItem's setView isn't called again with the new view  
instance. I don't know if this is a bug -- maybe Cocoa does some  
voodoo in the swapping from the proxy NSView object to the custom  
view.


Standard views work fine: eg. NSButton and NSBox.

Has anyone successfully used IB to create toolbar items with custom  
views?


Thanks,
Gunnar



___

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/jhess%40apple.com

This email sent to jh...@apple.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


CURLHandle - getting header status

2009-05-11 Thread Charles E. Heizer

Hello,
I'm trying to use CURLHandle to get the header status of the request  
just made but I'm unable to get the status code. I'm trying to use  
headerStatus but I get a unrecognized selector error.


What am I missing?
Thanks,
Charles


NSURL *url = [NSURL URLWithString:myURL];
CURLHandle *urlHandle = [[CURLHandle alloc] initWithURL:url cached:NO];
[urlHandle prepareAndPerformCurl];

NSData *result = [urlHandle resourceData];

// This Works
NSLog(@headerString = %@,[urlHandle headerString]);

// This Does not work
NSLog(@headerStatus = %@,[urlHandle headerStatus]);
___

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: Creating NSAttributedString objects using WebKit in secondary thread

2009-05-11 Thread Dragan Milić

On uto 12. 05. 2009., at 00:16, Stephen J. Butler wrote:


2009/5/11 Dragan Milić mi...@mac.com:


So, I assume creating attributed strings is not thread safe, but I  
don't
remember anything like that stated in the documentation. In my  
opinion, that

looks like a bug.


It is thread safe... if you stick to the Foundation methods. The
method you're trying to use, however, is part of the AppKit additions.
Hence the non-thread safeness.

One way to do this might be to spawn a helper app that accepts data
somehow (mach ports might be fastest using vm copy-on-write techniques
IIRC, but harder to implement), render on that process's main thread,
and then pass the data back (NSAttributedString supports NSCoding).


Would I necessarily need another helper app? Can I fork another  
(child) process and implement server side in it, which would receive  
raw bytes and return encoded attributed strings, and subsequently  
implement client side in the parent process (in its secondary  
thread), which would send raw bytes and receive back encoded  
attributed strings?


Thanks for the hints.

Milke

___

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: Creating NSAttributedString objects using WebKit in secondary thread

2009-05-11 Thread Gwynne Raskind

On May 11, 2009, at 7:42 PM, Dragan Milić wrote:
So, I assume creating attributed strings is not thread safe, but I  
don't
remember anything like that stated in the documentation. In my  
opinion, that

looks like a bug.

It is thread safe... if you stick to the Foundation methods. The
method you're trying to use, however, is part of the AppKit  
additions.

Hence the non-thread safeness.

One way to do this might be to spawn a helper app that accepts data
somehow (mach ports might be fastest using vm copy-on-write  
techniques

IIRC, but harder to implement), render on that process's main thread,
and then pass the data back (NSAttributedString supports NSCoding).
Would I necessarily need another helper app? Can I fork another  
(child) process and implement server side in it, which would  
receive raw bytes and return encoded attributed strings, and  
subsequently implement client side in the parent process (in its  
secondary thread), which would send raw bytes and receive back  
encoded attributed strings?


This is workable, but make sure you use a fork()/exec() pair to re- 
execute yourself in that case, and use argc/argv in your main() to  
determine which mode to run in. Don't just use fork() by itself -  
there are severe limits to what you can do in an only-fork()ed  
process. What those limits are isn't entirely clear to me; perhaps  
someone else could elaborate on that?


-- Gwynne, Daughter of the Code
This whole world is an asylum for the incurable.

___

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: Creating NSAttributedString objects using WebKit in secondary thread

2009-05-11 Thread Michael Ash
2009/5/11 Dragan Milić mi...@mac.com:
 On pon 11. 05. 2009., at 20:07, Douglas Davidson wrote:

 On May 11, 2009, at 10:53 AM, Dragan Milić wrote:

 Is there any way to initialise and use WebKit out of the main thread?

 No, there isn't.  This is a fundamental restriction on the use of WebKit.

 Yes, I know. I just hoped there was some secret magical workaround which
 would enable me to create attributed strings in the main thread. The point
 is I'm trying to create something like Finder's Show icon preview
 functionality, trying to create graphical representations of some text files
 (which are kept in memory) but to still keep UI responsive if a user wants
 to scroll view etc.

There's no need for secret magic. Just use
performSelectorOnMainThread: to get some code to run on the main
thread. It can then do the NSAttributedString stuff. Of course it will
block the main thread for the duration of the operation, so if your
strings take a long time to convert then this is not ideal.

Mike
___

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: Creating NSAttributedString objects using WebKit in secondary thread

2009-05-11 Thread Michael Ash
2009/5/11 Gwynne Raskind gwy...@darkrainfall.org:
 This is workable, but make sure you use a fork()/exec() pair to re-execute
 yourself in that case, and use argc/argv in your main() to determine which
 mode to run in. Don't just use fork() by itself - there are severe limits to
 what you can do in an only-fork()ed process. What those limits are isn't
 entirely clear to me; perhaps someone else could elaborate on that?

The main problem is that fork() kills all other threads in the child
process, leaving you with only the thread that called fork() active.
These threads are killed instantly no matter what they were doing,
which means they could be holding exclusive resources. For example, if
a thread was in the middle of a malloc() and held malloc's lock, it
would never unlock and thus any calls you make to malloc() would
deadlock.

There are further troubles with shared resources like file
descriptors, and resources that don't convey across, like window
server connections, but in light of the inability to call even basic
libc functions, this is not so important.

For a list of what you can call, see the sigaction() man page. The
list of functions that are safe to call from a signal handler is the
same as what you can safely call between fork and exec.

Mike
___

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: Creating NSAttributedString objects using WebKit in secondary thread

2009-05-11 Thread Dragan Milić

On uto 12. 05. 2009., at 01:52, Michael Ash wrote:


2009/5/11 Dragan Milić mi...@mac.com:

On pon 11. 05. 2009., at 20:07, Douglas Davidson wrote:


On May 11, 2009, at 10:53 AM, Dragan Milić wrote:

Is there any way to initialise and use WebKit out of the main  
thread?


No, there isn't.  This is a fundamental restriction on the use of  
WebKit.


Yes, I know. I just hoped there was some secret magical workaround  
which

would enable me to create attributed strings in the main thread.


There's no need for secret magic. Just use
performSelectorOnMainThread: to get some code to run on the main
thread.


Yes I know, I've made an error while typing (was thinking in my native  
language and translating thoughts to English). That sentence should've  
read: I just hoped there was some secret magical workaround which  
would enable me to create attributed strings in the SECONDARY thread.


Thanks anyway.

Milke___

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


DVDPlayer Deinterlacing

2009-05-11 Thread Brad Gibbs

Hi,

It looks like the Scripting Bridge header file for Apple's DVD Player  
offers nearly the same options as the DVDPlayer framework, and neither  
seem to offer control over the deinterlacing options present in the  
DVD Player app itself.  Apple's deinterlacing actually became pretty  
respectable in 10.5 and I'd like at least the option to invoke it.


Is there any way to set deinterlacing in code, either through the  
Scripting Bridge or by using DVDPlayer.framework + some Quartz filter  
that didn't show up in my searches of the documentation?  If not, is  
deinterlacing turned on or off by default?


Also, I'm leaning towards using the DVDPlayer.framework.  Is there any  
strong reason I should use the Scripting Bridge approach instead?



Thanks.

Brad
___

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: Creating NSAttributedString objects using WebKit in secondary thread

2009-05-11 Thread Dragan Milić

On uto 12. 05. 2009., at 01:55, Michael Ash wrote:


2009/5/11 Gwynne Raskind gwy...@darkrainfall.org:
This is workable, but make sure you use a fork()/exec() pair to re- 
execute
yourself in that case, and use argc/argv in your main() to  
determine which
mode to run in. Don't just use fork() by itself - there are severe  
limits to
what you can do in an only-fork()ed process. What those limits are  
isn't

entirely clear to me; perhaps someone else could elaborate on that?


The main problem is that fork() kills all other threads in the child
process, leaving you with only the thread that called fork() active.


And that effectively invalidates fork()/exec() approach for me, since  
I cannot afford all other threads being killed.


Thanks for clarification.

Milke
___

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: Help debugging bindings issues

2009-05-11 Thread Alex Smith
Thank you so much for your help. I took a closer look at my  
ArrayController and found that I had bound the  
ArrayController.ContentObject to the NSMutableArray that was supposed  
to be bound to the ArrayControler.ContentArray. So I guess it was  
using something provided by a base class  to provide the ContentArray  
and thus my exception.  It is great to have this finally figured out!


Thanks,
Alex

On May 11, 2009, at 10:47 AM, Quincey Morris wrote:


On May 11, 2009, at 07:43, Alex Smith wrote:


Here is the full error listing.

2009-05-11 08:22:55.043 RaiseMan[2935:10b] [NSCFArray 0x158f90  
addObserver:forKeyPath:options:context:] is not supported. Key  
path: personName
2009-05-11 08:22:55.062 RaiseMan[2935:10b] [NSCFArray 0x16efb0  
addObserver:forKeyPath:options:context:] is not supported. Key  
path: personName
2009-05-11 08:22:55.067 RaiseMan[2935:10b] [NSCFArray 0x158f90  
addObserver:forKeyPath:options:context:] is not supported. Key  
path: expectedRaise
2009-05-11 08:23:02.160 RaiseMan[2935:10b] [NSCFArray 0x16efb0  
addObserver:forKeyPath:options:context:] is not supported. Key  
path: expectedRaise


I am not using an IBOutlet or IBAction for two reasons. 1) The  
author did not use them is his example (nor are they in his project  
code) and 2) I am binding personName and expectedRaise to the table  
columns.


Actually, the terminology works the other way round. You're binding  
the table columns to [something that gives you access to properties]  
personName and expectedRaise.


So Table Column binding is set to bind to Array Controler,  
Controller Key = Arranged Objects, model key path = personName.  
(same for expectedRaise).


That's perfectly fine. Note that the table column is actually bound  
to ArrayController.arrangedObjects -- that is to an array property  
of the ArrayController. For a specific row, the table view fetches  
the corresponding [non-array] object of that array, and extracts the  
desired properties (personName and expectedRaise) from that [non- 
array] object. Although we typically say that the column is bound  
to ArrayController.arrangedObjects.personName, that isn't literally  
true because that's not a valid key path. (And that's why controller  
key and model key are separate in the binding.)


This suggests that your problem is not the table column binding, but  
the ArrayController's content binding (or its content connection, if  
you're not using bindings there). According to the error message,  
the ArrayController's content is an array of arrays instead of an  
array of Person objects.



___

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/alex 
%40securesmith.net


This email sent to a...@securesmith.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 arch...@mail-archive.com


Re: Creating NSAttributedString objects using WebKit in secondary thread

2009-05-11 Thread Adam R. Maxwell


On May 11, 2009, at 2:56 PM, Dragan Milić wrote:


On pon 11. 05. 2009., at 20:07, Douglas Davidson wrote:


On May 11, 2009, at 10:53 AM, Dragan Milić wrote:

Is there any way to initialise and use WebKit out of the main  
thread?


No, there isn't.  This is a fundamental restriction on the use of  
WebKit.


Yes, I know. I just hoped there was some secret magical workaround  
which would enable me to create attributed strings in the main  
thread. The point is I'm trying to create something like Finder's  
Show icon preview functionality, trying to create graphical  
representations of some text files (which are kept in memory) but to  
still keep UI responsive if a user wants to scroll view etc.


So, I assume creating attributed strings is not thread safe, but I  
don't remember anything like that stated in the documentation. In my  
opinion, that looks like a bug.


For what it's worth, it's documented in the Leopard release notes:

http://developer.apple.com/releasenotes/Cocoa/AppKit.html

On 10.5, NSAttributedString will automatically use  
performSelectorOnMainThread for you, so if you want to always use a  
helper app, you'll have to figure out beforehand if it's HTML.





smime.p7s
Description: S/MIME cryptographic signature
___

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: NSToolbarItem with custom view in Interface Builder 3 (Leopard)

2009-05-11 Thread Gunnar Proppe

Howdy Jon,

Thanks for the tips, I'll give that a try. The first suggestion sounds close to 
where I was going to go, except I hadn't thought of instantiating the view in 
the NIB file. Great idea. 

Your alternative suggestion sounds interesting but I'm not sure I understand 
it. Would I then set the class name in the Identity pane of this pasted, plain 
NSView to my custom class? What's different about this plain NSView from the 
custom view dragged from the library?

Is this a bug in Interface Builder, or did I misread the linked documentation?

From the doc:

The procedure for adding a custom view item is very similar to that for a 
custom image item. (“Custom” in this context means any object from the 
Interface Builder library as well as instances of a custom NSView subclass.) 
Just drag any view object from the library onto the Allowed Toolbar Items area. 
Click the item once and press Command-1 to display the Attributes pane for the 
object as a toolbar item; click again to edit the attributes of the item as 
itself. You should modify the size of the custom view item in the Size pane of 
the inspector, not directly. If you drag a Custom View object into the 
allowed-items set, click it twice and set the name of the custom NSView class 
in the Identity pane of the inspector (Command-6).

Gunnar


- Original Message 
 From: Jonathan Hess jh...@apple.com
 To: Gunnar Proppe toneclus...@yahoo.com
 Cc: cocoa-dev@lists.apple.com
 Sent: Monday, May 11, 2009 4:35:49 PM
 Subject: Re: NSToolbarItem with custom view in Interface Builder 3 (Leopard)
 
 Hey Gunnar -
 
 You won't be able to make this work with an instance of custom view dragged 
 from the library. Here are a couple of suggestions for workarounds:
 
 You could add an outlet to the toolbar item you'd like to use a custom view 
 with, and then place the custom view at the top level of your NIB, and also 
 add 
 an outlet to it. In awakeFromNib, you could call setView: on the toolbar item 
 with the correct view.
 
 Alternatively, you could use a view object that wasn't a custom view. 
 Interface 
 Builder doesn't provide a view object in the library that isn't a specific 
 subclass or NSView, or a custom view, but you can get a hold of a plain 
 NSView 
 by copying and pasting one from someplace else. For example, copying a 
 window's 
 content view by using Interface Builder's outline view will get you a vanilla 
 instance of NSView. Paste one into the top level of a document and resize it 
 to 
 a reasonable size, and and then you can drag it from the document window into 
 the toolbar.
 
 Good Luck -
 Jon Hess
 
 On May 9, 2009, at 11:36 AM, Gunnar Proppe wrote:
 
  
  I followed the steps described here to set up a toolbar item with a custom 
 view in Interface Builder:
  
 http://developer.apple.com/documentation/Cocoa/Conceptual/Toolbars/Articles/ToolbarInIB.html
  
  Unfortunately my custom view's drawRect is never called. I verified that it 
 does get initialized. The toolbar item's min and max size are set up 
 properly. 
 Just to be safe I had my view conform to NSCoding but initWithCoder and 
 ecodeWithCoder aren't called. I tried various springs and struts settings 
 with 
 no results.
  
  Digging deeper, I subclassed NSToolbarItem and overrode setView and 
  setMinSize 
 so I could break on them. setMinSize is getting called with the correct 
 values. 
 Interestingly, setView gets called before my custom view is initialized. I 
 assume this is the proxy NSView object. Then my custom view is initialized 
 (initWithFrame) but the NSToolbarItem's setView isn't called again with the 
 new 
 view instance. I don't know if this is a bug -- maybe Cocoa does some voodoo 
 in 
 the swapping from the proxy NSView object to the custom view.
  
  Standard views work fine: eg. NSButton and NSBox.
  
  Has anyone successfully used IB to create toolbar items with custom views?
  
  Thanks,
  Gunnar
  
  
  
  ___
  
  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/jhess%40apple.com
  
  This email sent to jh...@apple.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


Resolving address on 10.4 (ppc) - problem with endianness

2009-05-11 Thread Alexander Hartner
I am using the following to resolve a Bonjour discovered service  
address. However it seems that getnameinfo on 10.4 (ppc) does not  
translate correctly. However using inet_ntoa  correctly resolved to an  
IP address. Ideally I am after the hostname, and if that cannot be  
resolved then the IP address. This is done nicely by getnameinfo on  
10.5 (intel) but seems to fail on 10.4 (ppc).



- (void)netServiceDidResolveAddress:(NSNetService *)aNetService
{
NSString * hostname = [aNetService hostName];
NSLog(@Host : %@,hostname);
NSLog(@Name : %@,[aNetService name]);

NSArray * addresses = [aNetService addresses];
struct sockaddr *address;
if([addresses count]  0)
{
address = (struct sockaddr *) [[addresses objectAtIndex:0] 
bytes];
int port = -1;

if(address-sa_family == AF_INET)
{
port = ntohs(((struct sockaddr_in *)address)-sin_port);
}
else if(address-sa_family == AF_INET6)
{
port = ntohs(((struct sockaddr_in6 
*)address)-sin6_port);
}
else
{
NSLog(@Socket Error: The socket supplied is not IPv4 or 
IPv6);
return;
}

char * some_addr;
		some_addr = inet_ntoa(((struct sockaddr_in *)address)-sin_addr); //  
return the IP

printf(HostName inet_ntoa : %s\n, some_addr); // prints 
10.0.0.1


		//Do a reverse lookup on the DNS server or use the IP address of the  
server

char hostbuffer[NI_MAXHOST], serverbuffer[NI_MAXSERV];
		if (getnameinfo(address, address-sa_len, hostbuffer,  
sizeof(hostbuffer), serverbuffer, sizeof(serverbuffer), NI_NUMERICSERV))

{
NSLog(@Could not get numeric hostname);
}
		NSLog(@HostName nslog + getnameinfo : %s Server:  
%s,hostbuffer,serverbuffer);


printf(HostName printf + getnameinfo : %s \n, hostbuffer);
}   
}

Any suggestions on how to resolve this are truly appreciated.

Thanks in advance
Alex

smime.p7s
Description: S/MIME cryptographic signature
___

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: quick and dirty NSData implosion

2009-05-11 Thread Graham Cox


On 12/05/2009, at 6:20 AM, jon wrote:


@property(readwrite, assign) int bookMarkCount;
@property(readwrite, assign) NSString *bookMarkurlString;
@property(readwrite, assign) NSString *bookMarkTitle;


'assign' means the property is a simple assignment, such as ivar =  
foo; Therefore your strings are not going to end up owned by the  
bookmark object.


You want @property(retain) NSString* bookMarkTitle;



- (id)initWithCoder:(NSCoder *)c
{
[super init];



You do not and should not call [super init] here. In this case it's  
harmless as it happens, but in the general case it's not. The only  
thing initWithCoder is obliged to call is super's -initWithCoder: and  
ONLY when the object is not an immediate subclass of NSObject. In this  
case it is, so you should remove this line.




bookMarkCount = [c decodeIntForKey:@bookMarkCount];
bookMarkurlString = [c decodeObjectForKey:@bookMarkurlString];
bookMarkTitle = [c decodeObjectForKey:@bookMarkTitle];
return self;


Even if you fixed your property declarations, this is still not  
retaining the strings returned by the coder because you are assigning  
the ivars directly. The coder, in accordance with standard memory  
management rules, returns objects that you do not own, so if you wish  
to take ownership of them, they must be retained. The easiest way to  
ensure this is to declare the properties correctly, then use the  
accessors, so in -initWithCoder: you should do:


[self setBookMarkTitle:[coder decodeObjectForKey:@blahblah]];

So the reason that your strings are going missing is that they're not  
retained. When they are subsequently released by the objects that do  
own them (most likely an autorelease pool) your references are stale  
and no longer point to anything meaningful.




- (void)encodeWithCoder:(NSCoder *)c
{
[c encodeInt:bookMarkCount forKey:@bookMarkCount];
[c encodeObject:bookMarkurlString forKey:@bookMarkurlString];
[c encodeObject:bookMarkTitle forKey:@bookMarkTitle];
}




This is OK, but again it is probably advisable to use the property  
getter, since you have one:


[coder encodeObject:[self bookMarkTitle] forKey:@blahblah];

Then, if you change the way the title is implemented (using a format  
string, say) the archiving code doesn't need to be rewritten. There  
are times that you would deliberately want to ensure only the ivar was  
written, but those cases tend to be the exception, not the rule.



--Graham



___

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: quick and dirty NSData implosion

2009-05-11 Thread Adam R. Maxwell

On May 11, 2009, at 6:11 PM, Graham Cox wrote:


On 12/05/2009, at 6:20 AM, jon wrote:


- (id)initWithCoder:(NSCoder *)c

{

[super init];



You do not and should not call [super init] here. In this case it's  
harmless as it happens, but in the general case it's not. The only  
thing initWithCoder is obliged to call is super's -initWithCoder:  
and ONLY when the object is not an immediate subclass of NSObject.  
In this case it is, so you should remove this line.


Can you point to documentation on that?  The only thing I've seen says  
If the superclass of your class does not support NSCoding, you should  
invoke the superclass’s designated initializer instead of  
initWithCoder:.


http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/Archiving/Tasks/codingobjects.html#//apple_ref/doc/uid/2948




smime.p7s
Description: S/MIME cryptographic signature
___

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

NSAccessibilityAttributeValue exception raised when hovering mouse over top menu bar

2009-05-11 Thread Kevin Ross
Hi everyone, I'm experiencing a strange exception that is being thrown  
when I start the app in the debugger.  It loads the symbols fine and  
even starts the app okay.  But when I use the top menu at all (even  
just hovering the mouse over the menu bar does it) it raises this  
exception.  During a normal run, this isn't affecting the app's  
noticeably, but it does make it difficult to use the debugger with a  
breakpoint set on -[NSException raise] since it will break constantly  
when the mouse moves near the menu.  It appears that even command key  
equivalents do not bypass this.  I've just recently noticed this  
behavior, but I haven't worked on this project in about a month.  I  
believe that the last major change I made was replacing any non- 
localized user-visible strings with NSLocalizedStrings.  I don't  
remember seeing this after but might this be the culprit?


Also, here is the backtrace:
#0  0x930acc26 in -[NSException raise] ()
#1  0x94f2de4e in NSAccessibilityAttributeValue ()
#2  0x95218c3b in CopyAppKitUIElementAttributeValueNoCatch ()
#3  0x952190b7 in CopyAttributeValue ()
#4  0x929a2afc in _AXXMIGCopyAttributeValue ()
#5  0x929a9da1 in _XCopyAttributeValue ()
#6  0x929734d8 in mshMIGPerform ()
#7  0x930338e8 in CFRunLoopRunSpecific ()
#8  0x93033cd8 in CFRunLoopRunInMode ()
#9  0x943d62c0 in RunCurrentEventLoopInMode ()
#10 0x943d60d9 in ReceiveNextEventCommon ()
#11 0x943d5f4d in BlockUntilNextEventMatchingListInMode ()
#12 0x94e8cd7d in _DPSNextEvent ()
#13 0x94e8c630 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] ()

#14 0x94e8566b in -[NSApplication run] ()
#15 0x94e528a4 in NSApplicationMain ()
#16 0x2af2 in main (argc=5, argv=0xb5fc)


Thank you all for any suggestions you may have,

Kevin Ross



___

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


custom NSViews and subviews - creating in IB

2009-05-11 Thread Jack Carbaugh

I'm not sure if this is possible, but here goes:

I would like to create a subview with various controls in IB.

Then, in code, make a copy of that object and in turn make  
modifications to some of the objects in that view. For example, set a  
text field to a value.


Then, i'd like to add it to a super view.

Thanks for your help.
___

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


Debugger's global browser does not show any globals?

2009-05-11 Thread jon

I'm hoping someone has an easy answer for this,  or has seen it,

Most of the time,  when i'm in the debugger, if i go to the global  
option,  and i see the list of frameworks and my application,   if i  
click on anything, it shows 0/0 global variables...  basically nothing.


but every once in a while,  I'll see my application with the correct  
globals?   I'm not sure the difference...


I hope this is familiar to someone,  I'd love to figure this one  
out.   I hope it is not a common question...  not sure how to search  
the list yet.


thanks in advance,
Jon.
___

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: LaunchAgent Creation

2009-05-11 Thread Pierce Freeman
Thanks for your reply Jerry.  I'll try putting the -Rf before listing the
paths.  You mentioned newer and better methods in 10.4 and 10.5 and since I
am only planning to support these, could you give me a bit more detail to
what you are referring to.

-- In reply to:
You've almost got it.  I believe this might come close to working,
assuming for example that you want -Rf options on cp:

...
keyProgram/key
string/bin/cp/string
keyProgramArguments/key
array
string-R/string
stringf/string
string/source/path/string
string/destin/path/string
/array
...

By the way, if cp works for you, that's fine but there are newer and
better methods available in Mac OS 10.4, 10.5.


___

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: quick and dirty NSData implosion

2009-05-11 Thread Graham Cox


On 12/05/2009, at 11:36 AM, Adam R. Maxwell wrote:


On May 11, 2009, at 6:11 PM, Graham Cox wrote:


On 12/05/2009, at 6:20 AM, jon wrote:


- (id)initWithCoder:(NSCoder *)c

{

[super init];



You do not and should not call [super init] here. In this case it's  
harmless as it happens, but in the general case it's not. The only  
thing initWithCoder is obliged to call is super's -initWithCoder:  
and ONLY when the object is not an immediate subclass of NSObject.  
In this case it is, so you should remove this line.


Can you point to documentation on that?  The only thing I've seen  
says If the superclass of your class does not support NSCoding, you  
should invoke the superclass’s designated initializer instead of  
initWithCoder:.


http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/Archiving/Tasks/codingobjects.html#/ 
/apple_ref/doc/uid/2948



Ah, yes, I think what I'm saying can be misinterpreted. If you inherit  
from an object that implements NSCoding, your -initWithCoder: should  
call super's -initWithCoder:, but NOT super's designated (or any  
other) initializer. So in fact the OP's code is right, since NSObject  
doesn't implement NSCoding, though in that case we know NSObject's  
designated initializer doesn't do anything so it makes no difference  
whether it's there or not. In the interests of correctness though, it  
should be there, so I retract my advice.


What's a slight nuisance with this rule is that if I change what my  
class inherits from, I will have to revisit my -initWithCoder: method  
to possibly call super's initWithCoder: instead of super's designated  
initializer. If my method was calling [super init] on NSObject, that  
perfectly harmless call may now become harmful in the case I neglect  
to revisit that code. A more benign situation would be where NSObject  
implemented NSCoding but to be a no-op, then there would be one  
consistent rule for all initWithCoder: methods that was independent of  
the ancestry of the class. But that isn't the case so we're stuck with  
it I guess.


I think the situation where you have an object supporting NSCoding  
that inherits from something that doesn't, but isn't NSObject itself,  
is going to be pretty unusual.



--Graham


___

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 and retain.

2009-05-11 Thread jon
from my very limited Objective-C programing experience of all of 10  
days...


it appears to me that my assignments to NSStrings seem to, at random,  
disappear. (i, being a new Objective-C programmer coming from  
pascal and C,  like to have a global string in several places,  not  
that it is correct or anything, but i still would like to know what is  
going on when i do keep a string around for a good long time in the  
application)  (or any other object for that matter)


I attribute it so far to my lack of understanding garbage collection  
and retaining objects...


my wild guess right now is to do this below when ever i have the  
NSString instance assignment to prevent, for instance, theTitle  
from randomly disappearing...


ok,  tell me how badly this will go wrong... (although this would be  
more like theTitle is declared in an area that is global, and then  
assigned later.)


I do know that NSSTring is different than other objects,  but i'm  
not sure how,  they do appear to act like other objects though as far  
as i can tell.

thanks in advance,
Jon.

NSString *theTitle = [[defaults stringForKey:@the title] retain];

___

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: custom NSViews and subviews - creating in IB

2009-05-11 Thread Kevin Cathey

Hi Jack,

Your best bet is probably to create a new nib file that contains a top- 
level view which is your subview. Then, have outlets on the File's  
Owner that connect to your various controls like the text field (or  
just use bindings). In your code, then you would instantiate this nib  
as many times as you needed. For information on how to do this, see  
the Resource Programming guide:

http://developer.apple.com/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/1051i-CH4-SW8

Kevin

--
Kevin Cathey


On 11 May 2009, at 20:51, Jack Carbaugh wrote:


I'm not sure if this is possible, but here goes:

I would like to create a subview with various controls in IB.

Then, in code, make a copy of that object and in turn make  
modifications to some of the objects in that view. For example, set  
a text field to a value.


Then, i'd like to add it to a super view.

Thanks for your help.
___

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/cathey%40apple.com

This email sent to cat...@apple.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


Re: NSToolbarItem with custom view in Interface Builder 3 (Leopard)

2009-05-11 Thread Jonathan Hess


On May 11, 2009, at 6:03 PM, Gunnar Proppe wrote:



Howdy Jon,

Thanks for the tips, I'll give that a try. The first suggestion  
sounds close to where I was going to go, except I hadn't thought of  
instantiating the view in the NIB file. Great idea.


Your alternative suggestion sounds interesting but I'm not sure I  
understand it. Would I then set the class name in the Identity pane  
of this pasted, plain NSView to my custom class?


Yes.

What's different about this plain NSView from the custom view  
dragged from the library?


The Custom View has additional behavior beyond an NSView. One way  
they are different is that when a custom view is instantiated from a  
NIB file it receives the initWithFrame: message instead of  
initWithCoder:.




Is this a bug in Interface Builder, or did I misread the linked  
documentation?


This is a bug in Interface Builder.

Jon Hess



From the doc:

The procedure for adding a custom view item is very similar to that  
for a custom image item. (“Custom” in this context means any object  
from the Interface Builder library as well as instances of a custom  
NSView subclass.) Just drag any view object from the library onto  
the Allowed Toolbar Items area. Click the item once and press  
Command-1 to display the Attributes pane for the object as a toolbar  
item; click again to edit the attributes of the item as itself. You  
should modify the size of the custom view item in the Size pane of  
the inspector, not directly. If you drag a Custom View object into  
the allowed-items set, click it twice and set the name of the custom  
NSView class in the Identity pane of the inspector (Command-6).


Gunnar


- Original Message 

From: Jonathan Hess jh...@apple.com
To: Gunnar Proppe toneclus...@yahoo.com
Cc: cocoa-dev@lists.apple.com
Sent: Monday, May 11, 2009 4:35:49 PM
Subject: Re: NSToolbarItem with custom view in Interface Builder 3  
(Leopard)


Hey Gunnar -

You won't be able to make this work with an instance of custom  
view dragged

from the library. Here are a couple of suggestions for workarounds:

You could add an outlet to the toolbar item you'd like to use a  
custom view
with, and then place the custom view at the top level of your NIB,  
and also add
an outlet to it. In awakeFromNib, you could call setView: on the  
toolbar item

with the correct view.

Alternatively, you could use a view object that wasn't a custom  
view. Interface
Builder doesn't provide a view object in the library that isn't a  
specific
subclass or NSView, or a custom view, but you can get a hold of a  
plain NSView
by copying and pasting one from someplace else. For example,  
copying a window's
content view by using Interface Builder's outline view will get you  
a vanilla
instance of NSView. Paste one into the top level of a document and  
resize it to
a reasonable size, and and then you can drag it from the document  
window into

the toolbar.

Good Luck -
Jon Hess

On May 9, 2009, at 11:36 AM, Gunnar Proppe wrote:



I followed the steps described here to set up a toolbar item with  
a custom

view in Interface Builder:



http://developer.apple.com/documentation/Cocoa/Conceptual/Toolbars/Articles/ToolbarInIB.html


Unfortunately my custom view's drawRect is never called. I  
verified that it
does get initialized. The toolbar item's min and max size are set  
up properly.
Just to be safe I had my view conform to NSCoding but initWithCoder  
and
ecodeWithCoder aren't called. I tried various springs and struts  
settings with

no results.


Digging deeper, I subclassed NSToolbarItem and overrode setView  
and setMinSize
so I could break on them. setMinSize is getting called with the  
correct values.
Interestingly, setView gets called before my custom view is  
initialized. I
assume this is the proxy NSView object. Then my custom view is  
initialized
(initWithFrame) but the NSToolbarItem's setView isn't called again  
with the new
view instance. I don't know if this is a bug -- maybe Cocoa does  
some voodoo in

the swapping from the proxy NSView object to the custom view.


Standard views work fine: eg. NSButton and NSBox.

Has anyone successfully used IB to create toolbar items with  
custom views?


Thanks,
Gunnar



___

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/jhess%40apple.com

This email sent to jh...@apple.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 

Re: custom NSViews and subviews - creating in IB

2009-05-11 Thread Erik Buck
Do you have a question ?  Why don't you just  create a subview with  
various controls in IB.  Then, in code, make a copy of that object and  
in turn make modifications to some of the objects in that view. For  
example, set a text field to a value.  Then, add it to a super view.


You seem to know exactly what to do.  Which step eludes you ?
___

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: NSString and retain.

2009-05-11 Thread Clark Cox
On Mon, May 11, 2009 at 7:15 PM, jon trambl...@mac.com wrote:
 from my very limited Objective-C programing experience of all of 10 days...

 it appears to me that my assignments to NSStrings seem to, at random,
 disappear. (i, being a new Objective-C programmer coming from pascal and
 C,  like to have a global string in several places,  not that it is
 correct or anything, but i still would like to know what is going on when i
 do keep a string around for a good long time in the application)  (or any
 other object for that matter)

 I attribute it so far to my lack of understanding garbage collection and
 retaining objects...

There are two types of memory management with Objective-C on the Mac:

1. Retain/release

Under retain/release, every object has a reference count. -retain
increments this count, and -release decrements it. If the reference
count reaches zero, the object is deallocated.

2. Garbage Collection

Under garbage collection, the runtime keeps track of pointers in the
system that can keep an object alive. If any of these pointers point
to an object, then it will be kept alive. If any of these objects, in
turn, have pointers to other objects, those will be kept alive as
well, and so on. If an object no longer has any of these pointers
pointing to it, then the garbage collector will collect and finalize
it.

For the most part, unless you're writing framework code that can be
called from apps using both memory management models, you should pick
one and stick with it.

 my wild guess right now is to do this below when ever i have the NSString
 instance assignment to prevent, for instance, theTitle from randomly
 disappearing...

 ok,  tell me how badly this will go wrong... (although this would be more
 like theTitle is declared in an area that is global, and then assigned
 later.)

I'll assume that you're talking about the retain/release style of
memory management for now.

It would be best to read
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html,
and then ask specific questions about what you still don't understand.
Essentially, if you don't have an outstanding reference on the object,
it can and will go away when all of the other references on it are
released.

 I do know that NSSTring is different than other objects,  but i'm not
 sure how,  they do appear to act like other objects though as far as i can
 tell.

Then forget what you know :) . The memory management rules apply to
*all* objects, follow them, and all will be well. In places where some
classes (such as NSString) implement special behavior, the do so it a
way that nobody who follows the rules should ever notice.

 NSString *theTitle = [[defaults stringForKey:@the title] retain];

In this case, you are correct in retaining the object, as that is the
only to ensure that it remains valid for as long as you need it. You
also must make sure that, when you are ready to have theTitle point to
another object or nil, you release the old value of theTitle.

-- 
Clark S. Cox III
clarkc...@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


Re: NSString and retain.

2009-05-11 Thread Andy Lee

On May 11, 2009, at 10:15 PM, jon wrote:
my wild guess right now is to do this below when ever i have the  
NSString instance assignment to prevent, for instance, theTitle  
from randomly disappearing...


I hope the following doesn't sound harsh, because I'm not trying to  
be...


I'd second Clark's advice to read the docs on memory management, and  
come back with specific questions if you have any.  And I'd add that  
randomly disappearing is almost meaningless and gives us nothing to  
go on.  What specific behavior did you see?  Was there a crash, and if  
so, on what line of code?  Did the variable mysteriously become nil,  
and if so, how do you know -- did you use the debugger, did you use an  
NSLog statement, did a text field suddenly go blank?  How random is  
random?  Is it 100% reproducible?  Can you narrow it to a line of code?


ok,  tell me how badly this will go wrong... (although this would be  
more like theTitle is declared in an area that is global, and then  
assigned later.)


I do know that NSSTring is different than other objects,


What do you mean by this?  How do you know this?

Again, this is meant to help.  You'll get better results if you ask  
precise questions with actual code rather than paraphrases.  Your  
chances of getting a problem diagnosed are much better when people  
understand the problem clearly.


--Andy

 but i'm not sure how,  they do appear to act like other objects  
though as far as i can tell.

thanks in advance,
Jon.

NSString *theTitle = [[defaults stringForKey:@the title] retain];


___

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


Disabling menu item

2009-05-11 Thread Nikhil Khandelwal
Hi all,

I want to disable the complete menu item means it should not show any submenu 
when clicked on. Like in any application if I disable the file menu it should 
get disabled and not show any submenu related to it.
Please reply ASAP.

Thanks,
Nikhil


DISCLAIMER
==
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.
___

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


IKImageBrowserView is not reloading data.

2009-05-11 Thread Kenny Carruthers

Hi,

Given an IKImageBrowserView that is populated with valid  
IKImageBrowserItem, calling 'reloadData' on the image browser view  
does not actually reload the data for me. The documentation says that  
it Marks the receiver as needing its data reloaded but how and when  
does the reload actually take place?


My application is a Core Data application and I initially thought the  
problem was related to bindings and updating of the managed object  
behind the image views back, but then I came across the sample code at  
apple.dev and realized that the problem still existed:


http://developer.apple.com/samplecode/IKImageBrowserViewWithCoreData

So then I boiled it down to the most basic scenario I could think of  
and the problem still exists. I can trigger this bug with something  
as simple as an image view backed by data source that just returns  
IKImageBrowserItem, who's imageRepresentationType is  
IKImageBrowserPathRepresentationType and who's imageRepresentation is  
just a path on the local file system.


The following is reproducible for me. Hopefully I'm just missing  
something obvious. Comments are welcome.


1. Launch application
2. Populate image browser view with two items who return 'nil' when  
asked for their imageRepresentation. (ImageBrowser will correctly show  
the empty box for each.)
3. Click on a button that simply calls a method that assigns a valid  
path to each item. (The path represents an image on the disk.)
4. Call reloadData on the image browser and the empty boxes will  
correctly be replaced with the appropriate images.
5. Now, replace each items path with another valid path on the  
filesystem that points to a different photo.

6. Call reloadData.
7. This time, the images are not updated.

In fact, no matter what I seem to do, the only time I can actually get  
the image browser to reload the data is when the items don't return a  
valid imageRepresentation. All other times, the image browser view  
seems to ignore my requests for a reload, and doesn't even call any of  
the IKImageBrowserItem methods at all. (Though it does if the items  
are initially nill).


So, if the image browser view is already populated with valid items,  
the reload appears to fail for me. If the image browser view is  
populated with items that have an invalid imageRepresentation, the  
reload appears to work.


Thoughts?

Sincerely,
Kenny
___

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


Save dictionary to local file please help!

2009-05-11 Thread Ben Spam
Please help me, I'm in serious trouble if I do not sort this out!

I am trying to save a dictionary to a local file, but inserting a new record 
crashes my app and I can not fathom why, here is my code...please let me know 
if you see anything im doing wrong..
PS: the random key is purely for testing.

#import MyTestClass.h


@implementation MyTestClass
- (id) init
{
    self = [super init]; 
    
    //get path
    NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
NSUserDomainMask, YES);
    destinationPath = [[paths objectAtIndex:0] 
stringByAppendingPathComponent:@filePath.plist];
    //
    dataDict = [NSMutableDictionary 
dictionaryWithContentsOfFile:destinationPath];
    
    if(!dataDict){ NSLog(@No File); dataDict = [[NSMutableDictionary alloc] 
init];} else{[dataDict retain];}
    return self;
}
- (void) insertNewRecord:(NSMutableDictionary*)newRecord{
    [newRecord retain];
    [dataDict setValue: newRecord forKey: [NSString stringWithFormat:@test%d, 
(arc4random() % 1000)]  ];
 
    bool didSave = [dataDict writeToFile:destinationPath atomically:YES];

}


//singleton
static MyTestClass *myInstance = NULL;
+ (MyTestClass *)myTestClass
{
    @synchronized(self)
    {
        if (myInstance == NULL)
            myInstance = [[self alloc] init];
    }
    return(myInstance);
}

@end





___

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


Drawing 1 pixel line with zoom change

2009-05-11 Thread Sahana A

Hi There,

We have a feature in our application wherein we have to draw a 1 pixel  
line.  This drawing also varies relative to  the zoom factor of our  
view. For example
if we are drawing at a zoom factor of 200% we draw 0.5 pixel line.  
( basically: 1/zoomfactor width of line; 1 if  the zoomfactor  100 ).


For most of the times we succeed in drawing the 1 pixel line. However  
after we change the zoom factor, our drawing fails. Our 1 pixel

line is now drawn in 2 pixels.
For example: On changing the zoom values from say 100% to 300% and  
back to 100% again, the single pixel line sometimes draw in 2 pixels.
Even if the stroke width is set to 0.0 or 1.0, the stroked line will  
draw 2 pixels.


We have referred to the earlier posts in the mailing list and tried  
the alternatives mentioned there. We have used NSFrameRect of width or  
height equal to 1.

But on changing to zoom value to 66.7%, the line again draws 2 pixels.

Following is how our code looks like:
[NSGraphicsContext saveGraphicsState];
[[NSGraphicsContext currentContext] setShouldAntialias: FALSE];
NSRect rect = NSMakeRect(100.0, 100.0, 1.0, 200.0); //hardcoded for  
testing

NSFrameRect(rect);
[[NSGraphicsContext currentContext] setShouldAntialias: TRUE];//maybe  
this is not required.

[NSGraphicsContext restoreGraphicsState];

Following is the code used to change the zoom factor of the view:
- (void)scaleUnitSquareToSize:(NSSize)newUnitSize

Can you please give some inputs on this?

Thanks in advance.
Regards,
Sahana A


---
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an 
intended recipient, please notify the sender and delete all copies. Emails to 
and from our network may be logged and monitored. This email and its 
attachments are scanned for virus by our scanners and are believed to be safe. 
However, no warranty is given that this email is free of malicious content or 
virus.
___

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: quick and dirty NSData implosion

2009-05-11 Thread jon


On May 8, 2009, at 6:56 PM, Graham Cox wrote:

You can help yourself out with this type of thing by declaring your  
classes properly. If you need it to be NSCoding compliant (as you  
do), then ensure it subscribes to the protocol:


@interface BookMark : NSObject NSCoding



I think i have the Protocol set up correct now,  but i still have  
something incorrect,  I set up a test case to check it, and instance   
theBookMark does not return what was put into it in the last line of  
code below.


actually bookMarkCount  returns the correct integer, but the two  
strings are left as invalid?   just putting in constant strings rather  
than reading from a file makes the code smaller to test,  but produced  
the same result.


here is the class for BookMark, and the code below it that i used to  
test it theBookMark instance has the correct strings in it just  
before the last line of code.


Jon.

#import Cocoa/Cocoa.h

@interface BookMark : NSObject NSCoding
{
int bookMarkCount;
NSString *bookMarkurlString;
NSString *bookMarkTitle;
}

@property(readwrite, assign) int bookMarkCount;
@property(readwrite, assign) NSString *bookMarkurlString;
@property(readwrite, assign) NSString *bookMarkTitle;

@end


#import BookMark.h

@implementation BookMark

@synthesize bookMarkCount;
@synthesize bookMarkurlString;
@synthesize bookMarkTitle;

- (id)initWithCoder:(NSCoder *)c
{
[super init];
bookMarkCount = [c decodeIntForKey:@bookMarkCount];
bookMarkurlString = [c decodeObjectForKey:@bookMarkurlString];
bookMarkTitle = [c decodeObjectForKey:@bookMarkTitle];
return self;
}

- (void)encodeWithCoder:(NSCoder *)c
{
[c encodeInt:bookMarkCount forKey:@bookMarkCount];
[c encodeObject:bookMarkurlString forKey:@bookMarkurlString];
[c encodeObject:bookMarkTitle forKey:@bookMarkTitle];
}

@end



NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
BookMark *theBookMark = [[BookMark alloc] init];

	NSMutableDictionary *bookMarkList = [[NSMutableDictionary alloc]  
initWithCapacity: 1];


bookMarkCount++;
NSString *theurl = [defaults stringForKey:@the url];
NSString *theTitle = [defaults stringForKey:@the title];

[theBookMark setBookMarkCount:bookMarkCount];
[theBookMark setBookMarkurlString:theurl];
[theBookMark setBookMarkTitle:theTitle];


	NSString *countString = [NSString stringWithFormat:@%d,  
bookMarkCount];


[bookMarkList setObject:theBookMark forKey:countString];

	NSData *bookMarkdata = [NSKeyedArchiver  
archivedDataWithRootObject:bookMarkList];



[defaults setObject:bookMarkdata forKey:PECBookMarkListKey];
[defaults synchronize];


	bookMarkList = [NSKeyedUnarchiver  
unarchiveObjectWithData:bookMarkdata];


theBookMark = [bookMarkList objectForKey:countString];




___

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


instance management in IB

2009-05-11 Thread Chris Carson

Hello,

I've been scratching my head trying to get a basic delegate/data source 
Cocoa/AppKit program working and feel that I'm misunderstanding something basic 
(I've included the code is at the end).

I set a breakpoint within the if statement in the init method of MyModel and 
see it called more than once. The second time the debugger throws a 
EXC_BAD_ACCESS. This message goes away if I comment out the two lines in 
stepAnimation that call the getBuffer and getLength methods and then modify the 
buffer. All this makes me think that somehow the instance of MyModel is being 
deallocated as soon as the data source message returns, but before the data is 
copied into the pointBuffer.

I created an NSView and NSObject in Interface Builder, assigning the MyView 
subclass to the NSView object and MyModel to the NSObject object. Then I 
connected the dataSource outlet on MyView to th MyModel object.

What am I missing? How can I get the data from MyModel to be viewable my MyView?

Sidenote: Ultimately I'm trying to plot a real-time frequency spectrum. My plan 
is to pull in data over a CFMessagePort in the model and have the view access 
it view the data source.

Help is much appreciated!

Chris

main.m
--

int main(int argc, char *argv[]) {
// Launch Cocoa application
return NSApplicationMain(argc, (const char **) argv);
}

MyView.m:
--
@implementation MyView

- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
pointPath = [NSBezierPathbezierPath];
pointBuffer = malloc (sizeof(NSPoint) * 100);
[NSTimerscheduledTimerWithTimeInterval:0.1
target:self
selector:@selector(stepAnimation:)
userInfo:nil
repeats:YES];
}
return self;
}

- (void)drawRect:(NSRect)rect {
[pointPath removeAllPoints];
[pointPathappendBezierPathWithPoints:(NSPointArray)pointBuffercount:100];
[pointPathstroke];
}

- (void)setDataSource:(id)inDataSource {
dataSource = inDataSource;
}

- (id)dataSource {
returndataSource;
}

- (void)stepAnimation:(NSTimer *)timer {
float*inBuffer;
int i, length;


// Fetch buffer pointer
inBuffer = [[self dataSource] getBuffer:self];
length   = [[self dataSource] getLength:self];

// Copy to point buffer
for (i = 0; i  length; i++) {
pointBuffer[i].y = inBuffer[i];
pointBuffer[i].x = i;
}

// Mark display for painting
[selfsetNeedsDisplay:YES];
}

- (void)dealloc {
free(pointBuffer);
[super dealloc];
}

@end

MyView.h
--
@interface MyView : NSView {
IBOutletid dataSource;
NSBezierPath *pointPath;
NSPoint *pointBuffer;
}

- (void)setDataSource:(id)inDataSource;
- (id)dataSource;
- (void)stepAnimation:(NSTimer *)timer;

@end

@interface NSObject(MyViewDataSource)

- (float *)getBuffer:(MyView *)view;
- (int)getLength:(MyView *)view;

@end

MyModel.m
--
@implementationMyModel

- (id)init {
self= [superinit];
if (self) {
buffer = malloc (sizeof(float) * 100);
length = 100;
}
return self;
}

- (float *)getBuffer:(GraphView *)view {
returnbuffer;
}

- (int)getLength:(GraphView *)view {
returnlength;
}

- (void)dealloc {
free (buffer);
[super dealloc];
}

@end

MyModel.h
--
@interface MyModel : NSObject {
float *buffer;
int length;
}

- (float *)getBuffer:(GraphView *)view;
- (int)getLength:(GraphView *)view;

@end



  
___

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: Drawing 1 pixel line with zoom change

2009-05-11 Thread Graham Cox


On 12/05/2009, at 12:44 AM, Sahana A wrote:

We have a feature in our application wherein we have to draw a 1  
pixel line.  This drawing also varies relative to  the zoom factor  
of our view. For example
if we are drawing at a zoom factor of 200% we draw 0.5 pixel line.  
( basically: 1/zoomfactor width of line; 1 if  the zoomfactor  100 ).


For most of the times we succeed in drawing the 1 pixel line.  
However after we change the zoom factor, our drawing fails. Our 1  
pixel

line is now drawn in 2 pixels.
For example: On changing the zoom values from say 100% to 300% and  
back to 100% again, the single pixel line sometimes draw in 2 pixels.
Even if the stroke width is set to 0.0 or 1.0, the stroked line will  
draw 2 pixels.



It's not just a case of setting the line width, but also of placing  
the line where you want it. Strokes are placed so that they are  
centred on the co-ordinate, so half the line is above and half below  
the integral co-ordinate position. This is true even if you suppress  
anti-aliasing, which make matters worse since the lightening of the  
line is disabled and it'll draw as a solid 2 pixel line.


You need to truncate the line's co-ordinates to a whole number then  
add or subtract 0.5 so that the line is drawn on the pixel, not on the  
co-ordinate.


--Graham


___

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: beginner's question: having problems with saving/loading

2009-05-11 Thread Graham Cox


On 12/05/2009, at 5:42 AM, Gabriel Roth wrote:


I don’t know what’s calling the generic init method



So, set a breakpoint on it and have a look.

It sounds like you may have two instances of app controller being  
made, maybe one from code and the other from a nib. Maybe.


Your memory management is close to being broken too - do follow the  
usual links that get posted here several times a day to the relevant  
documentation.


--Graham


___

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: Save dictionary to local file please help!

2009-05-11 Thread Graham Cox


On 11/05/2009, at 7:10 PM, Ben Spam wrote:

dataDict = [NSMutableDictionary  
dictionaryWithContentsOfFile:destinationPath];



You do not own dataDict after this line, so later access to it is  
accessing a stale pointer, and ...kablooey... it falls over.


RTFDOMMA. (Read The Documentation On Memory Management. Again)

--Graham




___

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: Creating NSAttributedString objects using WebKit in secondary thread

2009-05-11 Thread Michael Ash
2009/5/11 Dragan Milić mi...@mac.com:
 On uto 12. 05. 2009., at 01:55, Michael Ash wrote:

 2009/5/11 Gwynne Raskind gwy...@darkrainfall.org:

 This is workable, but make sure you use a fork()/exec() pair to
 re-execute
 yourself in that case, and use argc/argv in your main() to determine
 which
 mode to run in. Don't just use fork() by itself - there are severe limits
 to
 what you can do in an only-fork()ed process. What those limits are isn't
 entirely clear to me; perhaps someone else could elaborate on that?

 The main problem is that fork() kills all other threads in the child
 process, leaving you with only the thread that called fork() active.

 And that effectively invalidates fork()/exec() approach for me, since I
 cannot afford all other threads being killed.

I think you've misunderstood. There is no problem with the fork/exec
approach here. The problem is with the approach of forking and *not*
calling exec, but running code directly in the child process after the
fork. This technique is rife with difficulty which is why virtually
nobody ever uses it. However, if you fork and then immediately exec,
you're fine, and apps do this all the time.

Mike
___

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: Creating an NSInvocation from an NSMethodSignature

2009-05-11 Thread Michael Ash
On Mon, May 11, 2009 at 9:04 AM, Mike Mangino
mmang...@elevatedrails.com wrote:
 I'm working on some changes to the OCMock framework to better support
 partial mocks and I'm a little stuck. In short, I'm trying to write a single
 method that I can attach to a class. I'm trying to make that method call
 through to the existing Mock recording code. It's based on NSProxy and
 expects to receive and NSInvocation.

 Creating the NSInvocation is easy. I'm not sure, however, how to fill in the
 parameters. The NSMethodSignature gives me the type encoding. Is there a way
 to use this information along with the address of the self parameter to fill
 in the params? I know how to get the type of each parameter, is there some
 way to convert the type string returned by getArgumentTypeAtIndex: to a
 size?

There is the NSGetSizeAndAlignment call, however I have heard that it
is buggy and you shouldn't use it.

One hack you might be able to do is to create a new NSMethodSignature
which uses that type as the return type, and then query
-methodReturnLength. This is ugly and evil, but it's the only other
built-in way I can think of.

Otherwise, you can build a comprehensive table for primitives without
much trouble. Where things get complicated is structs and unions.
Depending on your needs, you might punt on those entirely, or
implement a hardcoded check for common ones. You could of course
implement a full-fledged parser, but that's getting pretty crazy.

My suggestion would be, if at all possible, avoid creating the
NSInvocation manually at all. By far the nicest way to create an
invocation is by capturing it using the -forwardInvocation: method.
That way you create it using the same syntax you use to send any other
message, and the runtime takes care of all the icky details like
argument sizes.

Mike
___

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: quick and dirty NSData implosion

2009-05-11 Thread Michael Ash
On Mon, May 11, 2009 at 10:00 PM, Graham Cox graham@bigpond.com wrote:
 What's a slight nuisance with this rule is that if I change what my class
 inherits from, I will have to revisit my -initWithCoder: method to possibly
 call super's initWithCoder: instead of super's designated initializer. If my
 method was calling [super init] on NSObject, that perfectly harmless call
 may now become harmful in the case I neglect to revisit that code. A more
 benign situation would be where NSObject implemented NSCoding but to be a
 no-op, then there would be one consistent rule for all initWithCoder:
 methods that was independent of the ancestry of the class. But that isn't
 the case so we're stuck with it I guess.

You *always* have to revisit *all* of your initializers any time you
change superclasses. The available initializers and the designated
initializer(s) vary from one class to another. There's no change-free
approach available here. Even a no-op -initWithCoder: on NSObject
wouldn't save you, because what if you switched your superclass to
something which doesn't implement NSCoding but which requires an
initializer other than plain -init?

If you want to make your code more robust, you can always do an
if([SuperClass instancesRespondToSelector:_cmd]) check, but that's
still not foolproof due to the potential for needing another
initializer like I said.

Mike
___

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: Disabling menu item

2009-05-11 Thread Graham Cox


On 11/05/2009, at 4:53 PM, Nikhil Khandelwal wrote:

I want to disable the complete menu item means it should not show  
any submenu when clicked on. Like in any application if I disable  
the file menu it should get disabled and not show any submenu  
related to it.



If the parent item of a submenu is disabled, it doesn't show the  
submenu. So you could detect when all items in the menu were disabled  
and disable the parent, but this isn't done as standard - the usual UI  
is that a submenu's parent is always available even if it doesn't lead  
to anything you can actually choose. I guess this reflects the road  
map paradigm of menus as explained in the HIG.


--Graham


___

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: instance management in IB

2009-05-11 Thread Jonathan Hess

Hey Chris -

This line pointPath = [NSBezierPath bezierPath]; in the init method  
creates an NSBezierPath instance that may (will!) be destroyed with  
the next autorelease pool flush. You should be creating your bezier  
path with pointPath = [[NSBezierPath alloc] init]; and then add a  
[pointPath release] to your dealloc method.


http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html

Good Luck -
Jon Hess

On May 11, 2009, at 6:29 PM, Chris Carson wrote:



Hello,

I've been scratching my head trying to get a basic delegate/data  
source Cocoa/AppKit program working and feel that I'm  
misunderstanding something basic (I've included the code is at the  
end).


I set a breakpoint within the if statement in the init method of  
MyModel and see it called more than once. The second time the  
debugger throws a EXC_BAD_ACCESS. This message goes away if I  
comment out the two lines in stepAnimation that call the getBuffer  
and getLength methods and then modify the buffer. All this makes me  
think that somehow the instance of MyModel is being deallocated as  
soon as the data source message returns, but before the data is  
copied into the pointBuffer.


I created an NSView and NSObject in Interface Builder, assigning the  
MyView subclass to the NSView object and MyModel to the NSObject  
object. Then I connected the dataSource outlet on MyView to th  
MyModel object.


What am I missing? How can I get the data from MyModel to be  
viewable my MyView?


Sidenote: Ultimately I'm trying to plot a real-time frequency  
spectrum. My plan is to pull in data over a CFMessagePort in the  
model and have the view access it view the data source.


Help is much appreciated!

Chris

main.m
--

int main(int argc, char *argv[]) {
   // Launch Cocoa application
   return NSApplicationMain(argc, (const char **) argv);
}

MyView.m:
--
@implementation MyView

- (id)initWithFrame:(NSRect)frame {
   self = [super initWithFrame:frame];
   if (self) {
   pointPath = [NSBezierPathbezierPath];
   pointBuffer = malloc (sizeof(NSPoint) * 100);
   [NSTimerscheduledTimerWithTimeInterval:0.1
   target:self
   selector:@selector(stepAnimation:)
   userInfo:nil
   repeats:YES];
   }
   return self;
}

- (void)drawRect:(NSRect)rect {
   [pointPath removeAllPoints];
   [pointPathappendBezierPathWithPoints:(NSPointArray) 
pointBuffercount:100];

   [pointPathstroke];
}

- (void)setDataSource:(id)inDataSource {
   dataSource = inDataSource;
}

- (id)dataSource {
   returndataSource;
}

- (void)stepAnimation:(NSTimer *)timer {
   float*inBuffer;
   int i, length;


   // Fetch buffer pointer
   inBuffer = [[self dataSource] getBuffer:self];
   length   = [[self dataSource] getLength:self];

   // Copy to point buffer
   for (i = 0; i  length; i++) {
   pointBuffer[i].y = inBuffer[i];
   pointBuffer[i].x = i;
   }

   // Mark display for painting
   [selfsetNeedsDisplay:YES];
}

- (void)dealloc {
   free(pointBuffer);
   [super dealloc];
}

@end

MyView.h
--
@interface MyView : NSView {
   IBOutletid dataSource;
   NSBezierPath *pointPath;
   NSPoint *pointBuffer;
}

- (void)setDataSource:(id)inDataSource;
- (id)dataSource;
- (void)stepAnimation:(NSTimer *)timer;

@end

@interface NSObject(MyViewDataSource)

- (float *)getBuffer:(MyView *)view;
- (int)getLength:(MyView *)view;

@end

MyModel.m
--
@implementationMyModel

- (id)init {
   self= [superinit];
   if (self) {
   buffer = malloc (sizeof(float) * 100);
   length = 100;
   }
   return self;
}

- (float *)getBuffer:(GraphView *)view {
   returnbuffer;
}

- (int)getLength:(GraphView *)view {
   returnlength;
}

- (void)dealloc {
   free (buffer);
   [super dealloc];
}

@end

MyModel.h
--
@interface MyModel : NSObject {
   float *buffer;
   int length;
}

- (float *)getBuffer:(GraphView *)view;
- (int)getLength:(GraphView *)view;

@end




___

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/jhess%40apple.com

This email sent to jh...@apple.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


Re: instance management in IB

2009-05-11 Thread Patrick Mau

Hallo Chris

The NIB loading guide states that custom objects, like your model  
object,

are created using 'initWithCoder' and not plain 'init'.

I would advise you to implement 'awakeFromNib' in your view and use
NSLog() to print your datasource and its buffer or simply to set
a breakpoint there.

Regards
Patrick

On 12.05.2009, at 03:29, Chris Carson wrote:



Hello,

I've been scratching my head trying to get a basic delegate/data  
source Cocoa/AppKit program working and feel that I'm  
misunderstanding something basic (I've included the code is at the  
end).


I set a breakpoint within the if statement in the init method of  
MyModel and see it called more than once. The second time the  
debugger throws a EXC_BAD_ACCESS. This message goes away if I  
comment out the two lines in stepAnimation that call the getBuffer  
and getLength methods and then modify the buffer. All this makes me  
think that somehow the instance of MyModel is being deallocated as  
soon as the data source message returns, but before the data is  
copied into the pointBuffer.


I created an NSView and NSObject in Interface Builder, assigning the  
MyView subclass to the NSView object and MyModel to the NSObject  
object. Then I connected the dataSource outlet on MyView to th  
MyModel object.


What am I missing? How can I get the data from MyModel to be  
viewable my MyView?


Sidenote: Ultimately I'm trying to plot a real-time frequency  
spectrum. My plan is to pull in data over a CFMessagePort in the  
model and have the view access it view the data source.


Help is much appreciated!

Chris

main.m
--

int main(int argc, char *argv[]) {
   // Launch Cocoa application
   return NSApplicationMain(argc, (const char **) argv);
}

MyView.m:
--
@implementation MyView

- (id)initWithFrame:(NSRect)frame {
   self = [super initWithFrame:frame];
   if (self) {
   pointPath = [NSBezierPathbezierPath];
   pointBuffer = malloc (sizeof(NSPoint) * 100);
   [NSTimerscheduledTimerWithTimeInterval:0.1
   target:self
   selector:@selector(stepAnimation:)
   userInfo:nil
   repeats:YES];
   }
   return self;
}

- (void)drawRect:(NSRect)rect {
   [pointPath removeAllPoints];
   [pointPathappendBezierPathWithPoints: 
(NSPointArray)pointBuffercount:100];

   [pointPathstroke];
}

- (void)setDataSource:(id)inDataSource {
   dataSource = inDataSource;
}

- (id)dataSource {
   returndataSource;
}

- (void)stepAnimation:(NSTimer *)timer {
   float*inBuffer;
   int i, length;


   // Fetch buffer pointer
   inBuffer = [[self dataSource] getBuffer:self];
   length   = [[self dataSource] getLength:self];

   // Copy to point buffer
   for (i = 0; i  length; i++) {
   pointBuffer[i].y = inBuffer[i];
   pointBuffer[i].x = i;
   }

   // Mark display for painting
   [selfsetNeedsDisplay:YES];
}

- (void)dealloc {
   free(pointBuffer);
   [super dealloc];
}

@end

MyView.h
--
@interface MyView : NSView {
   IBOutletid dataSource;
   NSBezierPath *pointPath;
   NSPoint *pointBuffer;
}

- (void)setDataSource:(id)inDataSource;
- (id)dataSource;
- (void)stepAnimation:(NSTimer *)timer;

@end

@interface NSObject(MyViewDataSource)

- (float *)getBuffer:(MyView *)view;
- (int)getLength:(MyView *)view;

@end

MyModel.m
--
@implementationMyModel

- (id)init {
   self= [superinit];
   if (self) {
   buffer = malloc (sizeof(float) * 100);
   length = 100;
   }
   return self;
}

- (float *)getBuffer:(GraphView *)view {
   returnbuffer;
}

- (int)getLength:(GraphView *)view {
   returnlength;
}

- (void)dealloc {
   free (buffer);
   [super dealloc];
}

@end

MyModel.h
--
@interface MyModel : NSObject {
   float *buffer;
   int length;
}

- (float *)getBuffer:(GraphView *)view;
- (int)getLength:(GraphView *)view;

@end




___

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/pmau%40me.com

This email sent to p...@me.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


Re: quick and dirty NSData implosion

2009-05-11 Thread Andy Lee

On May 11, 2009, at 4:20 PM, jon wrote:

bookMarkurlString = [c decodeObjectForKey:@bookMarkurlString];
bookMarkTitle = [c decodeObjectForKey:@bookMarkTitle];


You need to retain these.  The doc for decodeObjectForKey: says  
Decodes and returns an autoreleased Objective-C object...


In general, when you have an invalid object reference, it's very  
likely you have a memory management bug.


Don't forget to release them in your dealloc method.

--Andy


___

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: instance management in IB

2009-05-11 Thread Chris Carson

Hi Jon,

Thanks! That did the trick -- I was way off.

Chris


- Original Message 
 From: Jonathan Hess jh...@apple.com
 To: Chris Carson cucar...@yahoo.com
 Cc: cocoa-dev@lists.apple.com
 Sent: Tuesday, May 12, 2009 1:19:11 AM
 Subject: Re: instance management in IB
 
 Hey Chris -
 
 This line pointPath = [NSBezierPath bezierPath]; in the init method creates 
 an 
 NSBezierPath instance that may (will!) be destroyed with the next autorelease 
 pool flush. You should be creating your bezier path with pointPath = 
 [[NSBezierPath alloc] init]; and then add a [pointPath release] to your 
 dealloc method.
 
 http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html
 
 Good Luck -
 Jon Hess
 
 On May 11, 2009, at 6:29 PM, Chris Carson wrote:
 
  
  Hello,
  
  I've been scratching my head trying to get a basic delegate/data source 
 Cocoa/AppKit program working and feel that I'm misunderstanding something 
 basic 
 (I've included the code is at the end).
  
  I set a breakpoint within the if statement in the init method of MyModel 
  and 
 see it called more than once. The second time the debugger throws a 
 EXC_BAD_ACCESS. This message goes away if I comment out the two lines in 
 stepAnimation that call the getBuffer and getLength methods and then modify 
 the 
 buffer. All this makes me think that somehow the instance of MyModel is being 
 deallocated as soon as the data source message returns, but before the data 
 is 
 copied into the pointBuffer.
  
  I created an NSView and NSObject in Interface Builder, assigning the MyView 
 subclass to the NSView object and MyModel to the NSObject object. Then I 
 connected the dataSource outlet on MyView to th MyModel object.
  
  What am I missing? How can I get the data from MyModel to be viewable my 
 MyView?
  
  Sidenote: Ultimately I'm trying to plot a real-time frequency spectrum. My 
 plan is to pull in data over a CFMessagePort in the model and have the view 
 access it view the data source.
  
  Help is much appreciated!
  
  Chris
  
  main.m
  --
  
  int main(int argc, char *argv[]) {
 // Launch Cocoa application
 return NSApplicationMain(argc, (const char **) argv);
  }
  
  MyView.m:
  --
  @implementation MyView
  
  - (id)initWithFrame:(NSRect)frame {
 self = [super initWithFrame:frame];
 if (self) {
 pointPath = [NSBezierPathbezierPath];
 pointBuffer = malloc (sizeof(NSPoint) * 100);
 [NSTimerscheduledTimerWithTimeInterval:0.1
 target:self
 selector:@selector(stepAnimation:)
 userInfo:nil
 repeats:YES];
 }
 return self;
  }
  
  - (void)drawRect:(NSRect)rect {
 [pointPath removeAllPoints];
 [pointPathappendBezierPathWithPoints:(NSPointArray)pointBuffercount:100];
 [pointPathstroke];
  }
  
  - (void)setDataSource:(id)inDataSource {
 dataSource = inDataSource;
  }
  
  - (id)dataSource {
 returndataSource;
  }
  
  - (void)stepAnimation:(NSTimer *)timer {
 float*inBuffer;
 int i, length;
  
  
 // Fetch buffer pointer
 inBuffer = [[self dataSource] getBuffer:self];
 length   = [[self dataSource] getLength:self];
  
 // Copy to point buffer
 for (i = 0; i  length; i++) {
 pointBuffer[i].y = inBuffer[i];
 pointBuffer[i].x = i;
 }
  
 // Mark display for painting
 [selfsetNeedsDisplay:YES];
  }
  
  - (void)dealloc {
 free(pointBuffer);
 [super dealloc];
  }
  
  @end
  
  MyView.h
  --
  @interface MyView : NSView {
 IBOutletid dataSource;
 NSBezierPath *pointPath;
 NSPoint *pointBuffer;
  }
  
  - (void)setDataSource:(id)inDataSource;
  - (id)dataSource;
  - (void)stepAnimation:(NSTimer *)timer;
  
  @end
  
  @interface NSObject(MyViewDataSource)
  
  - (float *)getBuffer:(MyView *)view;
  - (int)getLength:(MyView *)view;
  
  @end
  
  MyModel.m
  --
  @implementationMyModel
  
  - (id)init {
 self= [superinit];
 if (self) {
 buffer = malloc (sizeof(float) * 100);
 length = 100;
 }
 return self;
  }
  
  - (float *)getBuffer:(GraphView *)view {
 returnbuffer;
  }
  
  - (int)getLength:(GraphView *)view {
 returnlength;
  }
  
  - (void)dealloc {
 free (buffer);
 [super dealloc];
  }
  
  @end
  
  MyModel.h
  --
  @interface MyModel : NSObject {
 float *buffer;
 int length;
  }
  
  - (float *)getBuffer:(GraphView *)view;
  - (int)getLength:(GraphView *)view;
  
  @end
  
  
  
  
  ___
  
  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/jhess%40apple.com
  
  This email sent to jh...@apple.com



  

Re: Creating NSAttributedString objects using WebKit in secondary thread

2009-05-11 Thread Dragan Milić

On uto 12. 05. 2009., at 06:54, Michael Ash wrote:


I think you've misunderstood. There is no problem with the fork/exec
approach here.


You actually are spot on with that remark, my knowledge of UNIX system  
calls is not very broad, on the contrary it's rather limited I'd say.


Thank you all for the suggestions, I'll definitely investigate (read- 
try-learn) fork()/exec() route and any eventual question would be off- 
topic for this list anyway.


Milke
___

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