Re: NSXMLParser frees itself on error?

2009-05-04 Thread Stephen J. Butler
On Fri, May 1, 2009 at 1:59 AM, Mike Manzano
m...@instantvoodoomagic.com wrote:
 Note that the parser is aborted and released in here. This seems to work
 just fine, multiple times, with no problems. However, if I give it a URL to
 non-XML data (should be a 404 page somewhere), it calls
 parser:parseErrorOccurred: as expected. This method also calls
 -cleanupShowParsing. However, when it is called from here, the program
 eventually terminates with:

If I'm understanding this properly, the problem is that you're
releasing the parser from a delegate method. You can't do that because
then the delegate method will return to the (now) invalid context that
used to be the parser.
___

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: Writable dir for non-admin user outside user's dir

2009-05-04 Thread Erg Consultant
That's a pretty lame approach considering that Apple hides theirs.

Erg





From: Michael Ash michael@gmail.com
To: cocoa-dev cocoa-dev@lists.apple.com
Sent: Thursday, April 30, 2009 9:55:36 PM
Subject: Re: Writable dir for non-admin user outside user's dir

On Thu, Apr 30, 2009 at 7:24 PM, Erg Consultant
erg_consult...@yahoo.com wrote:
 One other thing I should mention: the location has to be non-obvious as the 
 files being written are DRM files and although I make them invisible, so all 
 variants of tmp, etc are out.

It's going to be trivial to track down where you're hiding it for
anybody who's even slightly familiar with the tools that OS X has to
offer. And once one person knows where it's kept, everybody knows
where it's kept. The only way you're going to be able to make it so
that nobody finds out where your DRM files are kept is if your product
is so unpopular that nobody cares to look. Stick them somewhere that
works, and don't bother trying to hide them.

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/erg_consultant%40yahoo.com

This email sent to erg_consult...@yahoo.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: Crashing resetting or releasing an NSManagedObjectContext

2009-05-04 Thread Daniel Kennett

Good morning all,

Thanks for your reply. Yes, I have code that triggers relationship  
faults, and removing that code solves the problem. However, I need  
that code to work! :-)


When fetching the data from the object tree, I call a method on the  
pet instance called -pertinentActions. This method loops through  
various relationships, calling -pertinentAction on each child object.  
I've ruled out the -pertinentAction method, since calling -className  
on the child objects also causes the crash to happen. I've also double  
and triple checked my retains and (auto)releases and they're all  
balanced.


Here's the code that triggers the crash:

-(NSArray *)pertinentActions {

NSMutableArray *actions = [[NSMutableArray alloc] init];

[actions addObject:[self birthdayAction]];

for (InsurancePolicy *policy in [self insurancePolicies]) {
KNClarusPertinentAction *action = [policy pertinentAction];

if (action) {
[actions addObject:action];
}
}

// If I return here, the later crash doesn't happen!

 for (VetVisit *visit in [self vetVisits]) {
[visit className];
}

// Returning just after this...

for (Medication *medication in [self medications]) {
[medication className];
}

// ... or this causes the later crash.

return [actions autorelease];
}

Commenting out the for (VetVisit* and for (Medication* loops fixes the  
crash. At this point, I'm doing no memory management at all - the - 
pertinentActions method is being called thusly:


NSManagedObjectContext *context = [[NSManagedObjectContext alloc] init];

Pet *pet = [KNClarusQuickDocumentParser petAtURL:url inContext:context];

NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];

[dict setValue:[[[pet valueForKey:@name] copy] autorelease]  
forKey:@name];
[dict setValue:[[[pet valueForKey:@birthday] copy] autorelease]  
forKey:@birthday];

// More copying of strings and dates
[..]
[dict setValue:[[[pet valueForKey:@pertinentActions] copy]  
autorelease] forKey:@pertinentActions]; // --- Here


[context release];

return [dict autorelease];

I think I've stumbled upon a problem with the way I've set up my  
model. The insurance policy collection, which doesn't crash after  
being accessed, is simply a one-to-many relationship from pet.  
However, the Medication and VetVisit relationships are a little more  
complex. It goes:


Pet - Medication(s) - Medication Course(s) - Medication Dose(s)
Pet - Vet Visit(s)

The Medication Dose entity has an optional relationship to Vet Visit  
in case the dose was given at a visit to the vet. Here's a screenshot  
of that part of my model:


http://www.kennettnet.co.uk/stuff/ClarusModel.png

Right now, I'm at a dead-end. I've ruled out my memory management, and  
can't see how I can work around what's happening, or what I'm doing  
wrong!


 Thanks,

-- Daniel

 ___

   dan...@kennettnet.co.uk
   http://www.kennettnet.co.uk

Please include previous messages in any reply you send.


Does the Pet class, or any class it has a relationship with,  
release or autorelease any VetVisit object? I am assuming that the  
Pet entity has a relationship to VetVisit--do you have any code  
that would cause the relationship fault to fire? If so, what happens  
when you comment that out?



On 29 Apr 2009, at 16:32, Alexander Spohr wrote:


Daniel,

You are trying to fetch an object and keep it - but you want to  
ignore / throw away the NSManagedObjectContext. This will never  
work. The NSManagedObjectContext keeps the object. Your Pet can  
not exist without its NSManagedObjectContext.


You should let the caller provide a NSManagedObjectContext and  
fetch your Pet into that context. Make it the callers  
responsibility to get a NSManagedObjectContext not yours.
+ (Pet *)petAtURL:(NSURL *)url inContext:(NSManagedObjectContext  
*)aManagedObjectContext


Or copy the pet into something like an NSDictionary and return that.

atze



Am 29.04.2009 um 10:59 schrieb Daniel Kennett:


Hi list,

I'm hoping you guys can help me. I'm loading up a Core Data  
store, copying some data out and attempting to clear it all up. I  
use this code for my Quicklook plugin, and in parts of my app for  
previewing documents in a more advanced manner than Quicklook  
provides.


This is how I set up my ManagedObjectContext:

+(Pet *)petAtURL:(NSURL *)url {

	NSManagedObjectModel *managedObjectModel = 	 
[KNClarusQuickDocumentParser managedObjectModel];
	NSPersistentStoreCoordinator *coordinator =  
[[[NSPersistentStoreCoordinator alloc]  
initWithManagedObjectModel:managedObjectModel] autorelease];


[coordinator addPersistentStoreWithType:NSSQLiteStoreType
  

Re: Modifying NSTableView cell data just prior to invoking field editor

2009-05-04 Thread Alastair Houghton

On 1 May 2009, at 04:49, Jim Correia wrote:

On Thu, Apr 30, 2009 at 11:38 PM, K. Darcy Otto do...@csusb.edu  
wrote:


Option 2: Moving the text displayed by the NSTableView to the right  
by some
way other than inserting spaces.  This might be the best way,  
alleviating
the need for a custom field editor and editing the field editor  
text prior

to display.  I'm not really sure how to do this though.


So you are inserted spaces into the value to achieve an fixed width  
indent?


Subclass NSTextFieldCell, and override -titleRectForBounds: to add
your left padding.


That's very likely the best method in this specific case, but it's  
also worth mentioning that if you want the normal display to be  
different from what the user gets to edit, you can use a custom  
NSFormatter subclass, together with NSFormatter's - 
editingStringForObjectValue: method.


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


Cocoa Drawing

2009-05-04 Thread DairyKnight
Hi, all


I'm trying to build a simple scribble program with Cocoa, and got some
questions I couldn't solve. Hope someone here could help.

1. How can I perform a proper drawing in somewhere else rather than
drawRect: ? Like the Win32 GetDC(HWND) and ReleaseDC. (Sorry I'd use lots of
Win32 analogy, coz
I've been a Win32 developer for quite a while.)
2. In the program what I did was respond to mouseDrag and call [NSView
display]. In drawRect I draw all the scribble lines using [NSBezierPath
strokeLineFromPoint]
But it seems the Mac Windows Manager would automatically clean out the whole
drawing area. Is there a way to avoid this? Like the InvalidRect(HWND, 0,
FALSE) in Win32.
3. I used NSTrackingArea first, but it seems not able to respond to
mouse move with button pressed. But mouseDrag would only respond to mouse
move with the left button
down. So there is no way to observe a mouse dragging with the right
button/mid button down on Mac??




Regards,
DairyKnight
___

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


Storing a password (iPhone)

2009-05-04 Thread Jelle De Laender

Hi

What is the best way to store a password on the iPhone?
I can't take the MD5 hash because I need to be able to work with the  
original password.


Should I create a custom class (with 2 strings) and save them with  
NSKeyedArchiver with the idea: nobody will read the files (it's  
impossible: except when you JailBreak) or what should you do?

Maybe I can simply use the NSUserDefaults?

Kind regards
Jelle
___

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: Why is NSString-FSRef so hard?

2009-05-04 Thread Uli Kusterer

On 29.04.2009, at 15:15, Mark Douma wrote:
If you are working with file paths, you shouldn't be using  
componentsSeparatedByString:, nor should you be defining / to be  
the component you should be separating by. What if someone had your  
app inside of a folder they named Apps/Utilities? The HFS+  
filesystem actually uses a colon as the path separator, so having  
a / in the name of a file or folder is perfectly acceptable, but  
would likely cause a headache and unexpected results if your code  
were to encounter it. (Go to the Finder and try adding a /).



Errr... No.

This is very misleading. While it is true that HFS and HFS+ use a  
colon as the path separator on disk, all Cocoa and POSIX APIs on the  
Mac swap colons and slashes before you ever get to see them. The only  
case where you as a programmer see this difference is in Finder, in  
CoreServices File Manager calls (fka Carbon File Manager), and when  
you call displayNameAtPath:.


Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de





___

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: Why is NSString-FSRef so hard?

2009-05-04 Thread Uli Kusterer

On 30.04.2009, at 13:12, Alastair Houghton wrote:
3. AFAIK the Carbon layer maps them back again.  Carbon's filesystem  
functions are implemented on top of the BSD layer, not alongside it  
as some people assume (OK, OK, there is the .vol special folder  
and there are a couple of additional entry-points that Carbon uses  
that are really SPI rather than API, but they're still BSD-level  
things).



 In defense of those some people, it should be mentioned that this  
has changed over time. AFAIK, in 10.0 Carbon and POSIX (I'm lumping  
together anything that uses POSIX paths here) took two parallel, but  
mostly separate paths, leading to fun bugs like permissions being  
ignored in some cases.


 At some later MacOS revision, this was changed to have one common  
pipeline. Since not every description gets updated with every system  
revision, it's easy to see how people could get confused.


Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de





___

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 a custom hierarchical list view

2009-05-04 Thread jonat...@mugginsoft.com


On 30 Apr 2009, at 21:55, Daniel Thorpe wrote:

Hi everyone, I'm wondering if anyone can put me on the right path to  
create the following custom view...


I'm trying to write a new view, to displaying hierarchical data  
which only uses one column. To navigate though the hierarchy, double  
clicking an item in the list loads that items contents into the  
list, and sets the list header to the name of the item.  
Additionally, I want to have a back button in the list header to  
go back up the hierarchy (something that looks similar to the arrow  
used in iTunes to switch between selected and playing artwork).


I've briefly thought about subclassing or otherwise constraining  
NSOutlineView or NSBrowser, but I think that might well make things  
unnecessarily complicated. So far I've thought that it'll need the  
following classes:


NSOutlineView is very flexible. You often don't need to subclass it.  
It is fairly easy to concoct a range of NSCell subclasses to provide  
custom behaviour.

Delegate methods allow you to manipulate the cells at will eg:
- (void)outlineView:(NSOutlineView *)anOutlineView willDisplayCell: 
(id)aCell forTableColumn:(NSTableColumn *)aTableColumn item:(id)item


It's true that NSOutlineView is fairly complex but there is a lot to  
be gained in working to understand its complexity.
If it was me I would work to exhaust the possibilities of using  
NSOutlineView before attempting to construct an alternative.



NSView subclasses:
DTList, DTListHeader

So far, the DTList creates an NSMatrix for DTListCell cell class,  
and sets this to the document view of an NSScrollView, which is  
added as a subview. Additionally it'll add a DTListHeader as a  
subview. This is a mixture of what NSBrowser and NSTableView have.


My DTList's initWithFrame: method looks like this at the moment...

- (id)initWithFrame:(NSRect)frame {
   self = [super initWithFrame:frame];
   if(self) {

// Enable subview resizing
[self setAutoresizesSubviews:YES];

	// An NSMatrix is contained within an NSScrollView (the document  
view)
	self.matrix = [[NSMatrix alloc] initWithFrame:frame cellClass: 
[DTListCell class] numberOfRows:1 numberOfColumns:1];

[matrix setAllowsEmptySelection:NO];
	[matrix setAutoresizingMask:NSViewWidthSizable |  
NSViewHeightSizable];


// The view contains an NSScrollView
// Leave space for the header
NSRect scrollViewFrame = frame;
scrollViewFrame.size.height -= kDTListHeaderHeight;

	NSScrollView *scrollView = [[NSScrollView alloc]  
initWithFrame:scrollViewFrame];

// Configure scroll view
[scrollView setHasVerticalScroller:YES];
[scrollView setHasHorizontalScroller:NO];
[scrollView setBorderType:NSNoBorder];
	[scrollView setAutoresizingMask:NSViewWidthSizable |  
NSViewHeightSizable];

[scrollView setDocumentView:matrix];

// Add the scroll view as a subview
[self addSubview:scrollView];

// Add a DTHeaderView
NSRect headerRect = frame;
headerRect.size.height = kDTListHeaderHeight;
headerRect.origin.y = NSMaxY(frame) - kDTListHeaderHeight;

self.header = [[DTListHeader alloc] initWithFrame:headerRect];
// Configure the header
[header setAutoresizingMask:NSViewWidthSizable];

// Add the header view as a subview
[self addSubview:header];

   }
   return self;
}


NSCell subclasses:
DTListHeaderCell, DTListCell

The DTListHeaderCell would actually inherit from NSActionCell as it  
need to use the target/action paradigm to navigate back up the  
hierarchy. DTListCell would be similar to NSBrowserCell, in that  
some will be lead nodes and other branch nodes. Those that are  
branch nodes need to draw a triangle (possibly a custom NSButton  
subclass) at their right hand side. Leaf nodes would just draw their  
string title.


Anyway, I've sort of come unstuck when it comes to the delegate/  
content bindings stuff. I'm not really sure how best to start when  
it comes to actually providing the objects of my hierarchy.


In terms of using a delegate, I have a protocol for DTList delegate,  
it can return the number of rows, but I don't really know where to  
write the code to create the DTListCell objects (presumably  
retrieving the titles from the delegate?). What would my drawRect:  
method look like on the DTList?


And if it used an NSTreeController? Well, I've go no idea how to  
setup the bindings for that!
Bind its content to an array containing objects of type NSTreeNode.  
The array elements become the top level branches in the tree.

Your tree is constructed using the documented NSTreeNode methods.
Your model objects are the NSTreeNode's 

Re: Modifying NSTableView cell data just prior to invoking field editor

2009-05-04 Thread K. Darcy Otto
Yes, I was inserting spaces to achieve a fixed-width indent; things  
are working much better now, thanks to your suggestion.


I tried overriding -titleRectForBounds in my NSTextViewCell subclass,  
but for some reason, it never gets called (not really sure why).  What  
I ended up doing was overriding -drawInteriorWithFrame:inView:, which  
does get called, and allowed me to reposition the frame prior to  
calling super.


One problem I ran into is that i need to have a different position for  
the rect based on the row, but I had no way for the subclass of  
NSTextViewCell to know which table cell was being drawn.  I solved  
this by creating a variable in the table that gets set with calls in  
the delegate to -tableView:willDisplayCell:forTableColumn:row:, and  
this variable can then be read in -drawInteriorWithFrame:inView:.  Is  
there a better way to determine which table cell is getting drawn?   
Seems a bit kludgy.


Thanks for your help.

On 30-Apr-09, at 8:49 PM, Jim Correia wrote:

On Thu, Apr 30, 2009 at 11:38 PM, K. Darcy Otto do...@csusb.edu  
wrote:


Option 2: Moving the text displayed by the NSTableView to the right  
by some
way other than inserting spaces.  This might be the best way,  
alleviating
the need for a custom field editor and editing the field editor  
text prior

to display.  I'm not really sure how to do this though.


So you are inserted spaces into the value to achieve an fixed width  
indent?


Subclass NSTextFieldCell, and override -titleRectForBounds: to add
your left padding.

- Jim


___

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: NSXMLParser frees itself on error?

2009-05-04 Thread Keary Suska

On May 1, 2009, at 12:59 AM, Mike Manzano wrote:

I have an NSXMLParser doing parsing the contents of a URL. It is  
allocated like this:


_showsParser = [[NSXMLParser alloc] initWithContentsOfURL:url];

Given a good URL to a parsable XML document, its  
parserDidEndDocument: method calls this method:


- (void) cleanupShowParsing {
[_buildingShows removeAllObjects];
[_showsParser abortParsing];
[_showsParser release];
_showsParser = nil;
_currentlyBuildingShows = NO;
}

Note that the parser is aborted and released in here. This seems to  
work just fine, multiple times, with no problems. However, if I give  
it a URL to non-XML data (should be a 404 page somewhere), it calls  
parser:parseErrorOccurred: as expected. This method also calls - 
cleanupShowParsing. However, when it is called from here, the  
program eventually terminates with:


2009-04-30 23:53:52.573 Revision3[49280:20b] PARSE ERROR: Error  
Domain=NSXMLParserErrorDomain Code=5 Operation could not be  
completed. (NSXMLParserErrorDomain error 5.)
objc[49280]: FREED(id): message shouldContinueAfterFatalError sent  
to freed object=0xf305a0


I have verified that 0xf305a0 is indeed _showsParser. Further, I've  
verified that if I don't release _showsParser in - 
cleanupShowParsing, no error occurs given a non-XML file.


My question is it the case that NSXMLParser frees itself if it  
encounters an error, but does NOT free itself on a successful parse  
of a document?


No Cocoa object (or Objective-C object, for that matter) instance will  
release itself to the point of deallocation (except in certain  
circumstances of a failed -init). To do so would violate memory  
management and object ownership. Something to keep in mind.


If I may propose a rule: never deallocate an object from one of its  
delegate method calls unless it is documented as specifically  
allowable. You don't know whether the object is complete and won't  
call any of its own methods right after the delegate call. So, don't  
call -cleanupShowParsing in -parser:parseErrorOccurred:, call it only  
from parserDidEndDocument:.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSSavePanel runModalForDirectory, set name selection?

2009-05-04 Thread Corbin Dunn


On Apr 30, 2009, at 1:28 PM, Henrietta Read wrote:


Question,

I'm passing a file name such as 'MyTextFile.txt' to NSSavePanel
runModalForDirectory.

When the panel appears the entire string is selected, but I would  
rather

that just
'MyTextFile' is selected. Is it possible to set the selection to  
exclude the

file
extension?


If you have the extension added to the allowedFileExtensions, then  
it should work automatically. Ideally, what you are doing should work  
anyways, and it is a bug; please do log a bug report for this.  
Unfortunately, there is no work around, as there is no API to access  
the private ivar that controls the name field.


corbin


___

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: ObjectAlloc and objects that should have been released

2009-05-04 Thread Miles
Hi guys-
 I'm still really struggling with this. I keep creating the most simple
examples I can and ObjectAlloc continues to show objects as 'created and
still living' when they really shouldn't be. At this point I would probably
just assume it's a bug in ObjectAlloc or elsewhere but over time my app is
using more memory so I do have issues to track down. This issues I'm seeing
make it really hard to narrow them down.

For example, I have created a new project where the delegate creates and
immediately releases a view controller that doesn't have anything in it at
all. Object alloc still shows a handful of objects as created and still
living, such as:

#Object AddressCategoryCreation TimeSizeResponsible
LibraryResponsible Caller
18770x527c30GeneralBlock-3200:01.44432ObjectAllocTest
-[ObjectAllocTestAppDelegate applicationDidFinishLaunching:]
18780x527540GeneralBlock-12800:01.444128
ObjectAllocTest-[ObjectAllocTestAppDelegate
applicationDidFinishLaunching:]
18790x5085f0GeneralBlock-12800:01.409128
ObjectAllocTeststart
18800x50ca20GeneralBlock-4800:01.44648ObjectAllocTest
-[MainViewController dealloc]
18810x5295c0GeneralBlock-3200:01.44432ObjectAllocTest
-[ObjectAllocTestAppDelegate applicationDidFinishLaunching:]
18820x50ab10GeneralBlock-4800:01.44648ObjectAllocTest
-[MainViewController dealloc]
18830x529970GeneralBlock-3200:01.44432ObjectAllocTest
-[ObjectAllocTestAppDelegate applicationDidFinishLaunching:]
18840x1013000GeneralBlock-153600:01.4441536
ObjectAllocTest-[ObjectAllocTestAppDelegate
applicationDidFinishLaunching:]

All of the ones that say [ObjectAllocTestAppDelegate
applicationDidFinishLaunching:] point to the line where I create mainMVC.
The ones that say to [MainViewController dealloc] point to [super
dealloc] (which seems very odd)

*Here's the entire appDelegate:*

#import ObjectAllocTestAppDelegate.h
#import MainViewController.h

@implementation ObjectAllocTestAppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(UIApplication *)application {

mainVC= [[MainViewController alloc] init];
[mainVC release];
mainVC = nil;

[window makeKeyAndVisible];
}


- (void)dealloc {
NSLog(@dealloc delegate);
[mainVC release];
[window release];
[super dealloc];
}


@end


*And here's the entire view controller:*


#import MainViewController.h

@implementation MainViewController

-(void)loadView {
}

- (id)init {
if (self = [super init]) {}
return self;
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}

- (void)dealloc {
NSLog(@dealloc mvc);
[super dealloc];
}


@end





On Sun, Apr 26, 2009 at 12:55 PM, Miles vardpeng...@gmail.com wrote:


 Wow. In that particular example it was '[UIScreen mainScreen]
 applicationFrame' that was causing the problem. When I changed that to a
 CGRectMake, the view was not longer living once I released it. Does
 '[UIScreen mainScreen] applicationFrame' cause some sort of caching issue?

 Now I'm at a point where this is keeping the view around longer than I
 think it should:

 NSDictionary *rootDict= [[NSDictionary alloc] initWithContentsOfFile:
 filePath];
 [rootDict release];

 Could someone please explain what this is all about?

 Thanks!




 On Sun, Apr 26, 2009 at 12:16 PM, Miles vardpeng...@gmail.com wrote:

 I've narrowed this down to the smallest case I can.

 I have a method that loads a view and immediately releases it:

 UIWindow *win= [UIApplication
 sharedApplication].keyWindow;
 TestVC *test = [[TestVC alloc] init];
 [win addSubview:test.view];
 [test.view removeFromSuperview];
 [test release];

 And here is the entire TestVC class:

 #import TestVC.h

 @implementation TestVC

 - (id)init
 {
 self = [super init];
 if (self){}
 return self;
 }

 // Implement loadView to create a view hierarchy programmatically, without
 using a nib.
 - (void)loadView {

 UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen
 mainScreen] applicationFrame]];
 contentView.backgroundColor = [UIColor blackColor];
 contentView.autoresizesSubviews = YES;
 [contentView release];
 }

 - (void)didReceiveMemoryWarning {
 [super didReceiveMemoryWarning];
 }

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

 @end


 When I look in ObjectAlloc, TestVC points to the UIView *contentView
 declaration as created and still living. Is this just an objectAlloc bug, or
 is there some other sort of autorelease thing that goes on behind the
 scenes? I don't see any reason why this would still be hanging around.

 Ugh.








 On Fri, Apr 24, 2009 at 7:18 PM, Miles vardpeng...@gmail.com wrote:

 Very interesting, I'll give all that a shot and report back. Thanks so
 much!




 On Apr 24, 2009, at 7:07 PM, Peter N Lewis 

Re: NSURLConnection unhappiness

2009-05-04 Thread Nick Hristov
Thank you all for your suggestions. I will use the runloop to wait on
response.

One more comment on self-ivar... I used this approach because using [self
connection] or self.connection (they are both the same thing) amount to an
extra message call.

Nick

On Thu, Apr 30, 2009 at 11:09 AM, Jeff Johnson 
publicpost...@lapcatsoftware.com wrote:

 On Apr 30, 2009, at 12:53 AM, Kyle Sluder wrote:

  On Thu, Apr 30, 2009 at 1:44 AM, Jeff Johnson
 publicpost...@lapcatsoftware.com wrote:

 On an unrelated note, your use of self-connection, etc., is
 non-standard
 and not advised. You should be using direct ivar access connection,
 properties self.connection, or accessor methods [self connection].


 Sure, `self-connection` is redundant with just plain old
 `connection`, but they amount to the same thing.  Unless there's some
 new-runtime trickery going on that I'm not aware of.

 --Kyle Sluder


 It amounts to the same thing, but it's a bad habit to get into. It's
 redundant, as you say, for an object's own instance variables. And you
 shouldn't be trying to directly access the instance variables of other
 objects. According to the documentation, Marking instance variables @public
 defeats the ability of an object to hide its data. It runs counter to a
 fundamental principle of object-oriented programming—the encapsulation of
 data within objects where it’s protected from view and inadvertent error.
 Public instance variables should therefore be avoided except in
 extraordinary cases. Thus, except in extraordinary cases, there's no reason
 to use the object-ivar syntax.

 -Jeff


___

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: Threadsafe function help

2009-05-04 Thread Michael Ash
On Fri, May 1, 2009 at 1:21 AM, Ken Tozier kentoz...@comcast.net wrote:

 On May 1, 2009, at 12:59 AM, Michael Ash wrote:

 It locks up is not a very useful description. Use the debugger and
 find out *where* it locks up.

 I bracket calls to my KCLog function like so
 NSLog(@about to call KCLog);
 KCLog(@testing 1, 2, 3);
 NSLog(@KCLog exe OK);

 And what I see in the Xcode console is:
 about to call KCLog

 and that's it. It never make it to KCLog exe OK

Again, not very useful. You could be anywhere within that large KCLog
function. Use the *debugger* and find out exactly where it's locked
up.

 I'll wager it's due to your manipulation of GUI objects in that last
 method you posted, though. GUI objects can *only* be manipulated from
 the main thread. You apparently know about this, because you dump your
 append calls onto the main thread using performSelectorOnMainThread:,
 but you fail to do this for a bunch of other calls, like length and
 scrollRangeToVisible:.

 I could see where scrollRangeToVisible might cause a problem, but wouldn't
 length be OK since it is just reading a value, not changing it?

Absolutely not. It might update a cache, or trigger lazy evaluation of
something, or just read an object that's being changed elsewhere.

Rather than repeat a lengthy discussion, I recommend you read this:

http://www.mikeash.com/?page=pyblog/friday-qa-2009-01-09.html

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: NSXMLParser frees itself on error?

2009-05-04 Thread Jesper Storm Bache
I have not used NSXMLParser, but as far as I can tell from your email,  
cleanupShowParsing is called in response to a call to the parser  
delegate.
In that case, you should not release the parser (because it is calling  
your delegate and is on the stack).

Try using autorelease instead.

Jesper Storm Bache

On Apr 30, 2009, at 11:59 PM, Mike Manzano wrote:


Hi Folks,

I have an NSXMLParser doing parsing the contents of a URL. It is
allocated like this:

_showsParser = [[NSXMLParser alloc] initWithContentsOfURL:url];

Given a good URL to a parsable XML document, its parserDidEndDocument:
method calls this method:

- (void) cleanupShowParsing {
[_buildingShows removeAllObjects];
[_showsParser abortParsing];
[_showsParser release];
_showsParser = nil;
_currentlyBuildingShows = NO;
}

Note that the parser is aborted and released in here. This seems to
work just fine, multiple times, with no problems. However, if I give
it a URL to non-XML data (should be a 404 page somewhere), it calls
parser:parseErrorOccurred: as expected. This method also calls -
cleanupShowParsing. However, when it is called from here, the program
eventually terminates with:

2009-04-30 23:53:52.573 Revision3[49280:20b] PARSE ERROR: Error
Domain=NSXMLParserErrorDomain Code=5 Operation could not be
completed. (NSXMLParserErrorDomain error 5.)
objc[49280]: FREED(id): message shouldContinueAfterFatalError sent to
freed object=0xf305a0

I have verified that 0xf305a0 is indeed _showsParser. Further, I've
verified that if I don't release _showsParser in -cleanupShowParsing,
no error occurs given a non-XML file.

My question is it the case that NSXMLParser frees itself if it
encounters an error, but does NOT free itself on a successful parse of
a document?

Thanks!

Mikesmime.p7sATT1.txt


___

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: #import errors and @class warnings

2009-05-04 Thread Jeremy Pereira


On 30 Apr 2009, at 17:16, Dave DeLong wrote:


Hi Andre,

#import means that the compiler will only include the file once,  
thus eliminating re-declaration errors.  It does not, however,  
eliminate the problems introduced by circular dependencies (which is  
what you've got going here).


As a general rule, the only thing you should be #importing in a .h  
file are header files from classes that are not from your  
application or framework.  (Except protocols, which I don't know of  
a way to forward declare)


@protocol MyProtocol ;




Matt Gallagher discussed this recently on his excellent Cocoa With  
Love blog: http://cocoawithlove.com/2009/04/8-confusing-objective-c-warnings-and.html


Cheers,

Dave

On Apr 30, 2009, at 12:55 AM, Andre Doucette wrote:


Hi everyone!

I have noticed a problem in a few projects and don't understand  
why. I have found a work around, but it seems both unnecessary and  
a pain due to warnings.


For one example, I have two classes, AppController and  
NetworkController.


For the AppController class:
-
#import Foundation/Foundation.h
#import NetworkController.h
@interface AppController : NSObject {
NetworkController *networkController;
}

@implementation AppController
- (void)awakeFromNib {
	networkController = [[NetworkController alloc]  
initWithAppController:self];

}
@end

And for the NetworkController class:
-
#import Foundation/Foundation.h
#import AppController.h
@interface NetworkController : NSObject {
AppController *appController;
}
- (id)initWithAppController:(AppController *)inAppController;
@end

@implementation NetworkController
- (id)initWithAppController:(AppController *)inAppController {
self = [super init];
appController = inAppController;
return self;
}
@end

I want the two controllers to know about each other. The  
AppController object is created in the NIB file, and in it's  
awakeFromNib method, I create the NetworkController object, passing  
in a reference to itself.


When trying to compile this, I get a series of errors. In my  
AppController.m file, I get error: syntax error before  
AppController and warning: '@end' must appear in an  
@implementation context. In my NetworkController.m, I get error:  
syntax error before 'NetworkController'.


It seems that it doesn't like the double #import, but I thought the  
whole idea behind #import was that it ensured one-time includes. If  
I take either #import NetworkController.h or #import  
AppController.h and change them to forward declarations (that is,  
@class NetworkController; or @class AppController;), this works,  
but then I get a sprinkling of errors everywhere saying that  
methods may not be implemented.


Any thoughts?
Thanks!
Andre
___

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

This email sent to davedel...@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/adc%40jeremyp.net

This email sent to a...@jeremyp.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: #import errors and @class warnings

2009-05-04 Thread Dave DeLong


On May 1, 2009, at 11:32 AM, Jeremy Pereira wrote:


On 30 Apr 2009, at 17:16, Dave DeLong wrote:


(Except protocols, which I don't know of a way to forward declare)


@protocol MyProtocol ;


Oh, well, that would make sense.  =)

Thanks!

Dave
___

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 Across NSTableView Columns

2009-05-04 Thread Uli Kusterer

On 27.04.2009, at 00:29, K. Darcy Otto wrote:
I'm attempting to model a real-world table structure with an  
NSTableView.  Here is what the table structure might look like on  
paper (warning: ASCII art ahead):



 I hope you're not trying to duplicate the Windows table view with  
its lines indicating indentation depth. There are usability reasons  
why the Mac simply uses whitespace to indent its rows, and I wouldn't  
recommend adding lines to the indentation. The advantage of being able  
to count the lines is offset by the added clutter and by how busy lots  
of lines make your user interface.


 I wrote about this concept (though not about lines in table views in  
particular) here: http://zathras.de/blog-spacing-boxes-and-other-layout-things.htm


Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de





___

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


sheets

2009-05-04 Thread Jason Todd Slack-Moehrle

Hi All,

Does anyone have an example for creating a 'sheet' without using  
Interface Builder at all? I just am trying to display a sheet with  
some text and an OK button and have it dismissed when pressed.


-Jason
___

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: How to make NSSplitView not dragable

2009-05-04 Thread Uli Kusterer

On 28.04.2009, at 18:44, Ashish Tiwari wrote:
I have a horizontal NSSplitView, I want the splitter bar should  
remain in a fixed postion and user should not be able to change size  
of upper subview or lower subview by dragging it.

Note: Split bar should be visible but not be drag able.



 You don't need a split view in that case. Just create the two views  
and leave a little gap between them, and set the resize springs and  
struts accordingly. If you can't produce the desired results that way,  
you might have to write a bit of code to position the two subviews  
manually.


Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de





___

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: question about mutable vs. non-mutable

2009-05-04 Thread Erik Buck
The whole debate about mutable and immutable classes, the inheritance 
hierarchy, what it means to return a pointer to a supposedly immutable object, 
what it means to store a pointer to a supposedly immutable object, the 
substitutability principle of object oriented programming, whether 
alternative designs should have been used, comparisons to the const keyword in 
C++, documentation criticisms, and countless inane comments were conducted in 
1996.  There is nothing to add now (13 years later): 
http://groups.google.com/groups/search?hl=enas_q=immutableas_epq=as_oq=as_eq=num=100scoring=lr=as_sitesearch=as_drrb=qas_qdr=as_mind=1as_minm=1as_miny=1981as_maxd=1as_maxm=1as_maxy=2009as_ugroup=comp.sys.next.programmeras_usubject=as_uauthors=safe=off
___

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


NSOutlineView with NSImage and NSStrings

2009-05-04 Thread iseecolors
I would like to have an image and a string together in my  
NSOutlineView, but it is not clear to me how to do this.  Basically I  
want to do what iTunes appears to do (icons in front of the text  
descriptors).


My initial thought was to return and NSArray that contains and NSImage  
and NSString from the method:


- (id)outlineView:(NSOutlineView *)outlineView  
objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item


But apparently the returned id is just converted to an NSString. (if  
it only deals with strings, why support id?)


Is there support for this built in to do this, or will I need to  
subclass NSOutlineView and override the drawRect method?


Rich Collyer
___

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


Discussion on how to draw text like that seen in toolbars

2009-05-04 Thread Alex Kac
I know there was a discussion about this a few months ago on this  
list, but I cannot find the right terms to search for. The discussion  
was how to draw text so that it was sunken much like you see in the  
toolbar. I just remember there was a specific way recommended to do it  
and I can't find it. Drawing the text twice is more of a shadow  
effect, so I don't think that was it...


Alex Kac - President and Founder
Web Information Solutions, Inc.

Patience is the companion of wisdom.
--Anonymous




___

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


Make connections between One Button and two different NSObjects?

2009-05-04 Thread Jon
can you make two connections between One Button and two different  
NSObjects?


is it possible? to have two different IBActions go off?  or some other  
way of controlling a single button from two different objects?


I want a normal controller,   but then i want to hide,  and unhide the  
button from the actions of a different window


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


Question of .png and 'transparency'

2009-05-04 Thread Smith, Steven (MCP)
I'm not sure this is the list for this question, so apologies in advance if not.

I'm trying to work on a game that has several pieces. In my design it makes 
sense (I think) to you several .png files that would be overlayed on the 
playing board.

My questions:

a) should my code do the transparency for each piece so the background (say a 
starfield) show through

b) if not my code would the .png already be 'set' with transparency in place

I've not done game UI befores so this is new turf for me.

Thanks in advance for any help on a) or b).

___

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


NSPredicate relationship data?

2009-05-04 Thread Greg Robertson
How do I create a search predicate to include an attribute of another
entity to which there is a relationship?

here is a simplified example of what I mean:

Entity Meal with the attributes: type and foods, foods has a one to
many relationship with the Entity Food

Entity Food with attributes: name and meal,  meal has an inverse
relationship with the entity Meal


How can I create an NSPredicate to select all the distinct foods based
on the Meal attribute type?

I was thinking about something like:

-(void)initFindStuff:(NSInteger)TypeID
{
// standard setup
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@Food
inManagedObjectContext:userManagedObjectContext];
[request setEntity:entity];
// sort by name
NSSortDescriptor *sortByName = [[NSSortDescriptor alloc]
initWithKey:@name ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortByName, 
nil];
[request setSortDescriptors:sortDescriptors];

// this is where I am not sure
// *
NSPredicate *searchType = [NSPredicate predicateWithFormat:@type=%d, 
TypeID];
[request setPredicate:searchType];
[request setResultType:NSDictionaryResultType];
[request setReturnsDistinctResults:YES];
[request setPropertiesToFetch:[NSArray arrayWithObjects:@name,
@meal.type, nil]];
// ***

// the rest is pretty standard stuff to setup an array
[sortDescriptors release];
[sortByName release];
NSError *error;
NSMutableArray *mutableFetchResults = [[userManagedObjectContext
executeFetchRequest:request error:error] mutableCopy];
if (mutableFetchResults == nil)
{
// Handle the error.
}
[self setMyArray:mutableFetchResults];
[mutableFetchResults release];
[request release];
}


Can I use Obj-C 2.0 dot notation in an NSPredicate? If not how should
I setup the predicate?

Thanks

Greg
___

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


NSMetadataQuery and /usr/local

2009-05-04 Thread Gerriet M. Denkmann
In a Cocoa app of mine I do use NSMetadataQuery with  
kMDItemTextContent LIKE u_versionToString  and setSearchScopes:  
{some array including /usr/local/include).


I know that two files in my /usr/local/include do contain the string  
u_versionToString.


Nothing is found. Probably because Spotlight in it's infinite wisdom  
did decide not to confuse me with stuff in /usr.
(Wouldn't it be nice if Spotlight had some preference like Unix  
Expert (like the good old NextStep had) ? But I digress).


Ok, so I did:
mdimport /usr/local/include

A second later my query gets updated, the files for which I was  
looking appear and all is fine.


Until I open one of these files in some Editor.

The moment I do this, my query gets updated again, and the just opened  
file disappears.


And reappears when I do mdimport /usr/local/include again.

Silly and rather annoying game.

Question:
Is this a pure Spotlight problem (and so probably even off-topic in  
this list) or can I do something in my app to avoid this?


10.5.6

Kind regards,

Gerriet.

___

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


NSWorkspaceDidWakeNotification crash

2009-05-04 Thread Trygve Inda
I call:

[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
selector:@selector(wakeNotification:) name:NSWorkspaceDidWakeNotification
object:nil];


-(void)wakeNotification:(NSNotification*)note
{
  [self wake:nil]
}


-(void)wakeNotification:(NSNotification*)note
{
  [self performSelector:@selector(wake:nil:) withObject:nil afterDelay:0.0];
}

The second way works more oftern, but the first way crashes in various weird
ways:

0   libobjc.A.dylib   0x9557f688 objc_msgSend + 24
1   com.apple.AppKit  0x906836cc -[NSApplication run] + 892
2   com.apple.AppKit  0x906508a4 NSApplicationMain + 574


0   libobjc.A.dylib   0x9557f68c objc_msgSend + 28
1   com.apple.CoreText0x972392fd
TTableCacheImp::AddTable(TBaseFont const, unsigned int, __CFData const*) +
41
2   com.apple.CoreText0x97239213
TTableCache::CopyTable(TBaseFont const, unsigned int) const + 227
3   com.apple.CoreText0x97238fca
TBaseFont::CopyTable(unsigned int) const + 234
4   com.apple.CoreText0x9727d242
TcmapTable::TcmapTable(TBaseFont const) + 40
5   com.apple.CoreText0x97238ea5
TBaseFont::GetGlyphsForCharacters(unsigned short const*, unsigned short*,
long) const + 25
6   com.apple.CoreText0x9723d3b5
CTFontGetGlyphsForCharacters + 71
7   com.apple.AppKit  0x9072f56a -[__NSFontTypefaceInfo
_latin1MappingTableWithPlatformFont:hasKernPair:] + 320
8   com.apple.AppKit  0x9072f3d9 -[NSFont
_latin1MappingTable:] + 86
9   com.apple.AppKit  0x9072de6d
+[NSStringDrawingTextStorage
_fastDrawString:attributes:length:inRect:graphicsContext:baselineRendering:u
sesFontLeading:usesScreenFont:typesetterBehavior:paragraphStyle:lineBreakMod
e:boundingRect:padding:scrollable:] + 678
10  com.apple.AppKit  0x906bae5b
-[NSAttributedString(NSExtendedStringDrawing) boundingRectWithSize:options:]
+ 1253
11  com.apple.AppKit  0x9079da5f
-[NSAttributedString(NSStringDrawing) size] + 68


I am guessing that when the NSWorkspaceDidWakeNotification is received, the
system is not fully back to running and that by posting the event back to
the main loop, it gets run after things are back up and running.

Still, even the second way causes a crash sometimes.

Calling the wake method directly without putting the Mac to sleep never
crashes and gives the expected results. The wake method resets some timers,
reads some files, and sometimes polls a URL.

Ideas?

Trygve


___

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


Audio recording of internal sound data

2009-05-04 Thread John Hall
I've developed a commercial application that outputs MIDI instrumental  
sounds combined with the playback of AIFF files. I'd like to be able  
to record the app's output to a digital audio file like AIFF or MP3,  
etc. I've looked at Apple's docs to figure out how to do it but can't  
seem to find anything on point. There's a lot of info for recording  
from external devices like a microphone, but doesn't seem to be  
anything on recording the sound generated from within the app itself.


I've used soundflower with partial success to wrap the audio output  
back around to the default input, but I don't think this is a viable  
solution since the app is distributed to users with all types of  
computer knowledge.


Working with the AUHAL might be a solution, but I'm not sure that what  
I want is just connecting the output back to the input. It seems the  
data is already there inside QuickTime and I just need to figure out  
how to access it and use it directly as the input to my recording code  
(I've been using the QuickTime movie Sequence Grabber for recording).


Does anyone have any thoughts on how I might accomplish this?

Thanks!
John

___

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: Writable dir for non-admin user outside user's dir

2009-05-04 Thread Uli Kusterer

On 01.05.2009, at 01:24, Erg Consultant wrote:
One other thing I should mention: the location has to be non-obvious  
as the files being written are DRM files and although I make them  
invisible, so all variants of tmp, etc are out.



 There's a handy tool called FSEventer that shows me every file your  
application writes to. Considering that, non-obvious can only be on  
the moon.


 Just create several invisible files somewhere in a few standard  
locations you can write to. Casual home users will not bother tracking  
down all of them, so if one is missing you can restore it using the  
others.


Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de





___

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


[ANN] FeedbackReporter to Mantis integration

2009-05-04 Thread Simone Tellini

Hi,

I've just written a small php script to integrate the FeedbackReporter  
framework by Torsten Curdt with a Mantis bugtracking system.


For links, comments and suggestions: 
http://tellini.info/blog/archives/81-FeedbackReporter-and-Mantis-integration.html

--
Simone Tellini
http://tellini.info



___

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: Installer has admin permissions but installer plugins don't

2009-05-04 Thread Fritz Anderson

On 30 Apr 2009, at 7:31 PM, Erg Consultant wrote:

How can I get my installer plugin to run with the same admin  
permissions as my installer runs with?


You can't. Plug-ins work as part of the Installer.app application,  
which always runs with the privileges of the user who started it.  
Privileged parts of the application are done by helper tools or the  
scripts you supply, which are sub-launched from Installer.app.


For most purposes, it's enough for the plugin to write what it has  
learned into /tmp, for one of the scripts to act on.


— F

--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- http://x3u.manoverboard.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


Custom binding like NSCollectionView

2009-05-04 Thread Alejandro Rodriguez

Hello all,

	I'm making a custom controller that should behave like a mix of  
NSTableView and NSCollectionView but I'm having trouble with makings  
bindings for it. I want to be able to make bindings like the ones used  
in NSCollectionView (binded to the arrangedObjects keypath of a  
NSArrayController) NSCollectionView tracks the changes in the  
arrangedObjects in quite an elegant manner, for instance it knows what  
objects are removed when you set filter and animates them  
disappearing... I would like to do something similar to that but when  
I  get notified of a change thru observeValueForKeyPath: ofObject:  
change: context:   the change dictionary is quite useless because  
the new and old keys are both null. Could anyone please point me in  
the right direction or tell me if I'm following a dead end.


Thanks a lot and regards,

Alejandro Rodríguez___

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: Repositioning the Field Editor

2009-05-04 Thread Uli Kusterer

On 28.04.2009, at 04:19, K. Darcy Otto wrote:
I have a field editor which I need to reposition in my tableView –  
specifically, I need to move it a few pixels to the right.  The  
following post:



 I think it's kinda odd to want to change that in the field editor.  
The field editor is a reusable view provided when text editing needs  
to be done. The rect and styles for it come from whatever view (or  
cell in a view) requests the field editor and currently is first  
responder.


 You may have more luck subclassing NSTableView or whatever cell is  
used for the particular row you're working with.


Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de





___

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 bonjour name (MyMac.local.)

2009-05-04 Thread Alexander Hartner
When trying to connect to my website using NSURLConnection as shown  
below the application fails rather frequently, as it's not able to  
resolve the server name (MyMac.local.). This url address was  
discovered previously using bonjour. Usually this issue is resolved by  
opening up Safari Bonjour Bookmarks, but this is not really a  
solution. What I am looking for is to resolve the host address and  
then connect to it consistently.


To reproduce this issue I :
1.) Start the http service on MyMac.local.
2.) Connect to it from another client (Success)
3.) Put MyMac.local. to sleep
4.) Connect to it from another client (Fails - Server asleep - No  
problem)

5.) Wake MyMac.local. up
6.) Connect to it from another client (Fails - PROBLEM)
7.) Open up Safari Book Marks to find my service running on  
MyMal.local. listed or run dscacheutil -flushcache

8.) Connect to it from another client (Success - Problem resolved)

When it's working dumping the dscacheutil (dscacheutil -cachedump - 
entries host) shows the following


Working :
 Host   05/03/09 12:21:51   05/03/09 12:19:51 0
7   120

 Key: h_aliases:polaris.local. ipv4:1 ipv6:1
 Key: h_aliases:polaris.local. ipv6:1
 Key: h_aliases:polaris.local. ipv4:1
 Key: h_name:Polaris.local ipv4:1 ipv6:1
 Key: h_name:Polaris.local ipv6:1
 Key: h_name:Polaris.local ipv4:1

However once the server has been put to sleep it appears as.

Problem :
Host   05/03/09 13:19:57   05/03/09 12:23:25 2   2   
3600YES

 Key: h_name:polaris.local ipv4:1 ipv6:1

Even after waking it back up does not change this. However flushing  
the cache also resolve the problem.


I read up on NSNetService's resolve method, but that requires a  
service name which I don't have. Once I discover the server I  
construct a URL and store this in my configuration. Is there a way to  
resolve the name from a URL ?


This is an example client I use to debug this issue.

int main (int argc, const char * argv[])
{
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
   NSString * hostAddressString;
   if (argc == 2)
   {
 hostAddressString = [NSString stringWithUTF8String:argv[1]];
   }
   else
   {
 hostAddressString = @http://MyMac.local.:8080;;
   }
   NSLog(@Connect to  : %@,hostAddressString);
   NSURLRequest * request=[NSURLRequest requestWithURL:[NSURL  
URLWithString:hostAddressString]  
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];

   NSURLResponse * response;
   NSError * error;
   NSData * data;
   data = [NSURLConnection sendSynchronousRequest:request  
returningResponse:response error:error];
   //NSURLConnection *theConnection=[[NSURLConnection alloc]  
initWithRequest:request delegate:self startImmediately:YES];

   if (!data)
   {
 NSLog(@Pre-connect failed);
   }
   else
   {
 NSString * output = [[NSString alloc] initWithData:data  
encoding:NSUTF8StringEncoding];

 NSLog(output);
   }
   if (error)
   {
 NSLog(@Pre-connect failed : %i %@ %@,[error code],[error  
domain],[error localizedDescription]);

   }
   [pool drain];
   return 0;
}



___

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


FTP Client Framework

2009-05-04 Thread Ammar Ibrahim
I'm building a client/server app. The client and server communicate using
FTP. I added my own custom commands, since this application will be in a
controlled environment. The server part is done, now I'm working on the
client. What is the easiest framework/class to embed in my app? I looked
into ConnectionKit http://opensource.utr-software.com/connection/, built
the framework and included it into my app, but couldnt do anything further
as the framework is not documented. Does anyone know of a tutorial? The
sample code included didn't help much. Is there any other framework that is
documented and easy to use for the same purpose?
Thanks,
Ammar
___

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: NSXMLParser frees itself on error?

2009-05-04 Thread Fritz Anderson

On 1 May 2009, at 1:59 AM, Mike Manzano wrote:

My question is it the case that NSXMLParser frees itself if it  
encounters an error, but does NOT free itself on a successful parse  
of a document?


When parser:parseErrorOccurred: is sent, the parser is still running.  
You can't release it in the middle. If you do, I expect it to crash.


My experience has been that if you release it _after_ -[NSXMLParser  
parse], and not within a method the parser itself is using, the parser  
is neither under- nor over-released. In other words, it has to be  
released, error or no, after it has finished parsing.


— F

--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- http://x3u.manoverboard.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: NSXMLParser frees itself on error?

2009-05-04 Thread Kyle Sluder
Initializers must call -[self release] in case of an error.  This
means that in response to an error that occurs as part of
initialization, you must not release that object.

--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


NSImage initWithContentsOfURL slowness

2009-05-04 Thread Nirias
I am trying to grab an image from a network camera but performance is
horrible.  My code is:

NSLog(@refreshImage);

url = [NSURL 
URLWithString:@http://192.168.1.253/SnapshotJPEG?Resolution=640x480Quality=Precision;];
NSLog(@  setURL);

NSImage *image = [NSImage alloc];
NSLog(@  allocated image);

[image initWithContentsOfURL:url];
NSLog(@  initialized from URL);  // Big pause before this log message

[imageView setImage:image];
NSLog(@  done);


Occasionally this runs in about 1 second but usually there is a 10-20
second pause during the initWithContentsOfURL step.  I have verified
the camera is working just fine - Firefox and Safari reload the same
url instantaneously every time.

Any idea what I am doing wrong?

Thanks,  Nick
___

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


Undo with NSTextView in HICocoaView

2009-05-04 Thread Ryan Joseph
Are there any special steps for adding undo support for NSTextView if  
it's embedded in a HICocoaView? All the other edit commands are  
working but undo just gives me a beep. I created the NSTextView  
programatically also so maybe I simply forget to include something,  
although I'm not sure what that may be. The only obvious thing I did  
was to call setAllowsUndo: but that did not fix the problem. Thanks  
for your time.


Regards,
Josef

___

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


Why is -makeWindowControllers getting called twice?

2009-05-04 Thread David Scheidt
I'm trying to figure out why my NSPersistantDocuement subclass's - 
makeWindowControllers is getting called twice.  I'm also trying to  
figure out why a nib that I'm trying to load from a viewcontroller  
created by the window controller made by -makeWindowController isn't  
loading.  I'm willing to bet they're related.  I'm further willing to  
bet it's something I've done, but I'm stumped.


Some relevant bits of GDB:

gdb) where
#0  -[MyDocument makeWindowControllers] (self=0x10471d0,  
_cmd=0x9464d69c) at /./MyDocument.m:84
#1  0x946e8e02 in -[NSDocumentController  
openUntitledDocumentAndDisplay:error:] ()

#2  0x946e895f in -[NSDocumentController(NSInternal) _openUntitled] ()
#3  0x946e87b1 in -[NSApplication _doOpenUntitled] ()
#4  0x946e7e95 in -[NSApplication(NSAppleEventHandling)  
_handleAEOpen:] ()
#5  0x946e76bc in -[NSApplication(NSAppleEventHandling)  
_handleCoreEvent:withReplyEvent:] ()
#6  0x912ee43f in -[NSAppleEventManager  
dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()

#7  0x912ee14f in _NSAppleEventManagerGenericHandler ()
#8  0x95bb4648 in aeDispatchAppleEvent ()
#9  0x95bb457e in dispatchEventAndSendReply ()
#10 0x95bb4425 in aeProcessAppleEvent ()
#11 0x917279a5 in AEProcessAppleEvent ()
#12 0x946e4f91 in _DPSNextEvent ()
#13 0x946e4630 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] ()

#14 0x946dd66b in -[NSApplication run] ()
#15 0x946aa8a4 in NSApplicationMain ()
#16 0x2eee in main (argc=1, argv=0xb7e4) at /Users/dms/ 
Documents/w/main.m:13

(gdb) go
Undefined command: go.  Try help.
(gdb) cont
Continuing.
(gdb) continue
2009-05-03 21:31:04.429 mwa3[61892:813] MANAgedobjectContext is  
NSManagedObjectContext: 0x104b220

(gdb) continue
(gdb) continue
2009-05-03 21:31:08.161 mwa3[61892:813] Cannot create NSSet from  
object BottlesDetailViewController: 0x104c470 of class  
BottlesDetailViewController

(gdb) where
#0  -[MyDocument makeWindowControllers] (self=0x105d5b0,  
_cmd=0x9464d69c) at /Users/dms/Documents/wine/mwa3-view/MyDocument.m:84
#1  0x946e8e02 in -[NSDocumentController  
openUntitledDocumentAndDisplay:error:] ()

#2  0x946e895f in -[NSDocumentController(NSInternal) _openUntitled] ()
#3  0x946e87b1 in -[NSApplication _doOpenUntitled] ()
#4  0x946e7e95 in -[NSApplication(NSAppleEventHandling)  
_handleAEOpen:] ()
#5  0x946e76bc in -[NSApplication(NSAppleEventHandling)  
_handleCoreEvent:withReplyEvent:] ()
#6  0x912ee43f in -[NSAppleEventManager  
dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()

#7  0x912ee14f in _NSAppleEventManagerGenericHandler ()
#8  0x9138459c in _NSAppleEventManagerPreDispatchHandler ()
#9  0x95bb4648 in aeDispatchAppleEvent ()
#10 0x95bb457e in dispatchEventAndSendReply ()
#11 0x95bb4425 in aeProcessAppleEvent ()
#12 0x917279a5 in AEProcessAppleEvent ()
#13 0x946e4f91 in _DPSNextEvent ()
#14 0x946e4630 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] ()

#15 0x946dd66b in -[NSApplication run] ()
#16 0x946aa8a4 in NSApplicationMain ()
#17 0x2eee in main (argc=1, argv=0xb7e4) at /Users/dms/ 
Documents/wine/mwa3-view/main.m:13

___

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: NSImage initWithContentsOfURL slowness

2009-05-04 Thread Nirias
More information:

My testing wasnt thorough enough:
While Firefox always loads rapidly, Safari has the same delay as cocoa, and
there is a clear pattern.  Two loads in 1-2 seconds, then the 3rd load takes
a really long time.  This pattern repeats with every 3rd load delayed,
whether loading NSImage from the url or refreshing in Safari.

My workaround for now is to hand code this simple HTTP Get operation,
putting the data into NSData and then initializing the NSImage from the
NSData.  Now it loads in 1/2 second or less, every time.

So it appears to be a webkit bug that afflicts both the Cocoa web
functionality as well as Safari.
___

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 a NSHTTPCookie

2009-05-04 Thread Chris

Hello,

I'm trying to create a NSHTTPCookie with this code:

//dictionary of attributes for the new cookie
	NSDictionary *newCookieDict = [NSMutableDictionary  
dictionaryWithObjectsAndKeys:@.example.com, NSHTTPCookieDomain,

   @Test 
Cookie, NSHTTPCookieName,
   @/, 
NSHTTPCookiePath,
   
@test12345, NSHTTPCookieValue,
   @2010-05-03 
21:02:41 -0700, NSHTTPCookieExpires, nil];
//create a new cookie
	NSHTTPCookie *newCookie = [NSHTTPCookie  
cookieWithProperties:newCookieDict];


//add the new cookie
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:newCookie];

When I try to set the newly created cookie to the  
sharedHTTPCookieStorage it doesn't ever get set.  Am I doing something  
wrong?


Thanks!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Integer as key in NSMutableDictionary

2009-05-04 Thread Weydson Lima
Hi,

Assume that:

NSMutableDictionary *result = [[NSMutableDictionary alloc]
initWithCapacity:10];
NSInteger ID;

And I add objects to the dictionary:

[result setObject:[NSArray arrayWithObjects: {... objects ...}
   nil]

   forKey:ID];

I am getting warnings when adding integers in the array and assigning
the integer ID as a key. The code does work though, but I am guessing
there is a better way to accomplish what I want. I know that these
methods are expecting pointers as parameters and I am passing a
scalar. So, what's the best way to approach that?

Thank 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


How to change the case of letters

2009-05-04 Thread rethish
Hi,

I am using the action methods uppercaseWord: and lowercaseWord: to change
the case of selected word.

-(IBAction)changecase:(id)sender
{
   if([[fontCasePopup titleOfSelectedItem] isEqualToString:@A])
{
   [textView uppercaseWord:sender];
}
else if([[fontCasePopup titleOfSelectedItem] isEqualToString:@a])
{
 [textView lowercaseWord:sender];
}
}

I want to change the case of letters rather than a complete word. And I
tried it with another action message:

[textView changeCaseOfLetter:sender];

But its not working. why is it so? Is there anything thing to be done?


Thank you in advance

rethish




___

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


NSPredicate relationship data?

2009-05-04 Thread Greg Robertson
How do I create a search predicate to include an attribute of another
entity to which there is a relationship?

here is a simplified example of what I mean:

Entity Meal with the attributes: type and foods, foods has a one to
many relationship with the Entity Food

Entity Food with attributes: name and meal,  meal has an inverse
relationship with the entity Meal


How can I create an NSPredicate to select all the distinct foods based
on the Meal attribute type?

I was thinking about something like:

-(void)initFindStuff:(NSInteger)TypeID
{
// standard setup
   NSFetchRequest *request = [[NSFetchRequest alloc] init];
   NSEntityDescription *entity = [NSEntityDescription
entityForName:@Food
inManagedObjectContext:userManagedObjectContext];
   [request setEntity:entity];
// sort by name
   NSSortDescriptor *sortByName = [[NSSortDescriptor alloc]
initWithKey:@name ascending:YES];
   NSArray *sortDescriptors = [[NSArray alloc]
initWithObjects:sortByName, nil];
   [request setSortDescriptors:sortDescriptors];

// this is where I am not sure
// *
   NSPredicate *searchType = [NSPredicate
predicateWithFormat:@type=%d, TypeID];
   [request setPredicate:searchType];
   [request setResultType:NSDictionaryResultType];
   [request setReturnsDistinctResults:YES];
   [request setPropertiesToFetch:[NSArray arrayWithObjects:@name,
@meal.type, nil]];
// ***

// the rest is pretty standard stuff to setup an array
   [sortDescriptors release];
   [sortByName release];
   NSError *error;
   NSMutableArray *mutableFetchResults = [[userManagedObjectContext
executeFetchRequest:request error:error] mutableCopy];
   if (mutableFetchResults == nil)
   {
   // Handle the error.
   }
   [self setMyArray:mutableFetchResults];
   [mutableFetchResults release];
   [request release];
}


Can I use Obj-C 2.0 dot notation in an NSPredicate? If not how should
I setup the predicate?

Thanks

Greg
___

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


Problem with the list?

2009-05-04 Thread Robert Martin

Hi,

I haven't received any posts for several days now, on any of the Apple  
lists I'm subscribed to...Is this a known problem, or should I check  
with my ISP?


Thanks, Rob
___

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 a NSHTTPCookie

2009-05-04 Thread Chris

Hello,

I'm trying to create a NSHTTPCookie with this code:

//dictionary of attributes for the new cookie
	NSDictionary *newCookieDict = [NSMutableDictionary  
dictionaryWithObjectsAndKeys:@.example.com, NSHTTPCookieDomain,

   @Test 
Cookie, NSHTTPCookieName,
   @/, 
NSHTTPCookiePath,
   
@test12345, NSHTTPCookieValue,
   @2010-05-03 
21:02:41 -0700, NSHTTPCookieExpires, nil];
//create a new cookie
	NSHTTPCookie *newCookie = [NSHTTPCookie  
cookieWithProperties:newCookieDict];


//add the new cookie
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:newCookie];

When I try to set the newly created cookie to the  
sharedHTTPCookieStorage it doesn't ever get set.  Am I doing something  
wrong?


Thanks!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Full content of Cocoa Design Patterns available as Rough-Cut on-line

2009-05-04 Thread Erik Buck
The full content of the forthcoming book, Cocoa Design Patterns, is now 
available as Rough-Cut on-line:
http://my.safaribooksonline.com/9780321591210?portal=informit
___

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: NSPopUpButtonCell Keeps on Trackin'! Demo, Movie

2009-05-04 Thread Jerry Krinock


I was able to fix this thing based on Jim Correia's clue:

On 2009 Apr 26, at 15:29, Jim Correia wrote:


What you've done is 
started a menu tracking session while the table view was already in
the middle of a mouse tracking session.


So I removed my override of -[NSTableView  
tableView:mouseDownInHeaderOfTableColumn:].


Instead, I subclassed NSTableHeaderView (which, it turns out, I needed  
to do anyhow to patch around some other unpredictable behavior),  
overrode its -mouseDown:, and moved my code into there.


Now, it doesn't keep on trackin' any more, and everything seems to work.

If someone could point me to some documentation on a mouse tracking  
session, I might be able to understand why my first approach didn't  
work.


Thanks,

Jerry 
___


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


Programmatically Changing Display(s) to Greyscale

2009-05-04 Thread Grant Erickson
While the Displays preference pane doesn't appear to allow it, the Universal
Access preference pane allows setting all active, online displays to
greyscale mode.

However, when using CGDisplayAvailableModes, the only modes that appear for
the current display width and height are 8-bit, 16-bit and 32-bit RGB modes
(3 samples per pixel).

Is there a Cocoa, CoreGraphics or other ApplicationServices API that handles
this mode selection or does this use an IOKit COM API? Given that
CGDisplayCurrentMode displays 32-bits, 3 samples per pixel even when
Universal Access is putting the displays in greyscale mode seems to hint at
the latter.

Regards,

Grant



___

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


NSOutlineView with NSImage and NSStrings

2009-05-04 Thread iseecolors
I would like to have an image and a string together in my  
NSOutlineView, but it is not clear to me how to do this.  Basically I  
want to do what iTunes appears to do (icons in front of the text  
descriptors).


My initial thought was to return and NSArray that contains and NSImage  
and NSString from the method:


- (id)outlineView:(NSOutlineView *)outlineView  
objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item


But apparently the returned id is just converted to an NSString. (if  
it only deals with strings, why support id?)


Is there support for this built in to do this, or will I need to  
subclass NSOutlineView and override the drawRect method?


Rich Collyer
___

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: Cocoa Drawing

2009-05-04 Thread Alex Kac


On May 1, 2009, at 5:20 AM, DairyKnight wrote:

   I'm trying to build a simple scribble program with Cocoa, and got  
some

questions I couldn't solve. Hope someone here could help.

   1. How can I perform a proper drawing in somewhere else rather than
drawRect: ? Like the Win32 GetDC(HWND) and ReleaseDC. (Sorry I'd use  
lots of

Win32 analogy, coz
I've been a Win32 developer for quite a while.)


Create an ivar context, draw your stuff in there. Then call  
setNeedsDisplay on the view and draw the contents of the context in  
drawRect.


Even in Win32 you are supposed to do the drawing only in WM_PAINT, not  
just anytime you want.



Alex Kac - President and Founder
Web Information Solutions, Inc.

If at first you don't succeed, skydiving is not for you.
-- Francis Roberts





___

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: Crashing resetting or releasing an NSManagedObjectContext

2009-05-04 Thread Alexander Spohr

You are still having the same error.

All your objects in the relationships are fetched. Therefore they are  
owned by the NSManagedObjectContext. You kill the  
NSManagedObjectContext by releasing it. After that point you are not  
allowed to touch any of its fetched objects. But you hand them out  
inside the NSDictionary.


Pleas reconsider my first tip and let the calling method create the  
NSManagedObjectContext. Use that to fetch all your objects, process  
them and _then_ kill your NSManagedObjectContext.


An NSManagedObject can not live without its NSManagedObjectContext.  
The NSManagedObjectContext ist the bucket that holds it. You can not  
take it out and throw the bucket away. Will not work.


atze



Am 01.05.2009 um 10:24 schrieb Daniel Kennett:


NSManagedObjectContext *context = [[NSManagedObjectContext alloc]  
init];


Pet *pet = [KNClarusQuickDocumentParser petAtURL:url  
inContext:context];


NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];

[dict setValue:[[[pet valueForKey:@name] copy] autorelease]  
forKey:@name];
[dict setValue:[[[pet valueForKey:@birthday] copy] autorelease]  
forKey:@birthday];

// More copying of strings and dates
[..]
[dict setValue:[[[pet valueForKey:@pertinentActions] copy]  
autorelease] forKey:@pertinentActions]; // --- Here


[context release];


^ this release kills all fetched objects.



return [dict autorelease];


^ this dict contains dead 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: Cocoa Drawing

2009-05-04 Thread Uli Kusterer


On 01.05.2009, at 12:20, DairyKnight wrote:


Hi, all


   I'm trying to build a simple scribble program with Cocoa, and got  
some

questions I couldn't solve. Hope someone here could help.

   1. How can I perform a proper drawing in somewhere else rather than
drawRect: ? Like the Win32 GetDC(HWND) and ReleaseDC. (Sorry I'd use  
lots of

Win32 analogy, coz
I've been a Win32 developer for quite a while.)
   2. In the program what I did was respond to mouseDrag and call  
[NSView
display]. In drawRect I draw all the scribble lines using  
[NSBezierPath

strokeLineFromPoint]
But it seems the Mac Windows Manager would automatically clean out  
the whole
drawing area. Is there a way to avoid this? Like the  
InvalidRect(HWND, 0,

FALSE) in Win32.


 Not sure what you're trying to do, but generally, the answer is you  
don't. You *always* draw from drawRect:. If you want to initiate  
drawing, call -setNeedsDisplay: or -setNeedsDisplayInRect: to tell  
AppKit that it should call drawRect on your view.


 For cases where that doesn't help, draw into an NSImage, then draw  
that from your drawRect. You can lockFocus on your NSImage at any  
time, then your view can draw it later as a whole.



  3. I used NSTrackingArea first, but it seems not able to respond to
mouse move with button pressed. But mouseDrag would only respond to  
mouse

move with the left button
down. So there is no way to observe a mouse dragging with the right
button/mid button down on Mac??



 rightMouseDragged: and otherMouseDragged:. They're just a couple  
lines down in NSResponder's header.


Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de





___

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: Storing a password (iPhone)

2009-05-04 Thread Greg Guerin

Jelle De Laender wrote:


What is the best way to store a password on the iPhone?
...
Maybe I can simply use the NSUserDefaults?



Use Keychain Services.  Google keywords:
  iphone keychain

  -- GG

___

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: Cocoa Drawing

2009-05-04 Thread Nick Zitzmann


On May 1, 2009, at 4:20 AM, DairyKnight wrote:


   1. How can I perform a proper drawing in somewhere else rather than
drawRect: ? Like the Win32 GetDC(HWND) and ReleaseDC. (Sorry I'd use  
lots of

Win32 analogy, coz
I've been a Win32 developer for quite a while.)


You can lock and then unlock focus on a view manually to draw into it,  
though you probably shouldn't do this unless you have a really good  
reason. I'd recommend you keep all drawing code in -drawRect: and then  
use the needs-display methods if you need to invalidate something.


   2. In the program what I did was respond to mouseDrag and call  
[NSView
display]. In drawRect I draw all the scribble lines using  
[NSBezierPath

strokeLineFromPoint]
But it seems the Mac Windows Manager would automatically clean out  
the whole
drawing area. Is there a way to avoid this? Like the  
InvalidRect(HWND, 0,

FALSE) in Win32.


Did you see the -setNeedsDisplayInRect: method in NSView?


   3. I used NSTrackingArea first, but it seems not able to respond to
mouse move with button pressed. But mouseDrag would only respond to  
mouse

move with the left button
down. So there is no way to observe a mouse dragging with the right
button/mid button down on Mac??


Did you see the -rightMouseDragged: and -otherMouseDragged: methods in  
NSResponder (NSView's superclass)?


Nick Zitzmann
http://www.chronosnet.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: Storing a password (iPhone)

2009-05-04 Thread Greg Parker

On May 1, 2009, at 4:58 AM, Jelle De Laender wrote:

What is the best way to store a password on the iPhone?
I can't take the MD5 hash because I need to be able to work with the  
original password.


Should I create a custom class (with 2 strings) and save them with  
NSKeyedArchiver with the idea: nobody will read the files (it's  
impossible: except when you JailBreak) or what should you do?

Maybe I can simply use the NSUserDefaults?


Use the Keychain. The Keychain is intended to have better security  
properties than anything you could build yourself.


The Keychain Services Programming Guide contains examples for saving  
and retrieving a password on iPhone.


In particular, a simple save it in a file solution is insecure if  
the file is included in an iPhone backup and the attacker gets a copy  
of the backup data. The Keychain is included in backup, but its data  
is encrypted and can only be decrypted with a key that never leaves  
the device.



--
Greg Parker gpar...@apple.com Runtime Wrangler


___

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: ObjectAlloc and objects that should have been released

2009-05-04 Thread Bill Bumgarner

On May 1, 2009, at 8:32 AM, Miles wrote:
For example, I have created a new project where the delegate creates  
and
immediately releases a view controller that doesn't have anything in  
it at
all. Object alloc still shows a handful of objects as created and  
still

living, such as:

#Object AddressCategoryCreation TimeSize 
Responsible

LibraryResponsible Caller
18770x527c30GeneralBlock-3200:01.44432 
ObjectAllocTest

-[ObjectAllocTestAppDelegate applicationDidFinishLaunching:]
18780x527540GeneralBlock-12800:01.444128
ObjectAllocTest-[ObjectAllocTestAppDelegate
applicationDidFinishLaunching:]
18790x5085f0GeneralBlock-12800:01.409128
ObjectAllocTeststart
18800x50ca20GeneralBlock-4800:01.44648 
ObjectAllocTest

-[MainViewController dealloc]
18810x5295c0GeneralBlock-3200:01.44432 
ObjectAllocTest

-[ObjectAllocTestAppDelegate applicationDidFinishLaunching:]
18820x50ab10GeneralBlock-4800:01.44648 
ObjectAllocTest

-[MainViewController dealloc]
18830x529970GeneralBlock-3200:01.44432 
ObjectAllocTest

-[ObjectAllocTestAppDelegate applicationDidFinishLaunching:]
18840x1013000GeneralBlock-153600:01.4441536
ObjectAllocTest-[ObjectAllocTestAppDelegate
applicationDidFinishLaunching:]

All of the ones that say [ObjectAllocTestAppDelegate
applicationDidFinishLaunching:] point to the line where I create  
mainMVC.

The ones that say to [MainViewController dealloc] point to [super
dealloc] (which seems very odd)


Your code is tickling quite a bit of framework code, still.  If the  
above allocations are truly leaks, that is bad.  However, they may  
likely be caches, items that briefly live beyond the current release  
pool, internal infrastructure that is lazily initialized or any of a  
number of other bits of memory used to implement the frameworks.


Just like multithreading, you can't assume anything about what happens  
when you call into framework code.


If you want to figure out where this memory is coming from, you'll  
need-- at the least-- the allocation backtrace of each block.


But that is likely not very interesting unless they represent a  
seriously large consumer of memory and you want to figure out what you  
did to trigger the allocation.


The real question is whether or not you see said allocations piling up  
over time.   If you run your code such that you do said simple task  
repeatedly, do you see a pileup of similar allocations?   Even if you  
do, that still doesn't mean there is a leak -- it could be a cache  
that will eventually start evicted items once it hits a certain size  
threshold.


Run your code in a loop for a long while and see if you see heap growth.

b.bum


___

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: Cocoa Drawing

2009-05-04 Thread Marcel Weiher


On May 1, 2009, at 3:20 , DairyKnight wrote:

   I'm trying to build a simple scribble program with Cocoa, and got  
some

questions I couldn't solve. Hope someone here could help.

   1. How can I perform a proper drawing in somewhere else rather than
drawRect: ? Like the Win32 GetDC(HWND) and ReleaseDC. (Sorry I'd use  
lots of

Win32 analogy, coz


You almost certainly don't want to do that, especially not if you  
can't get the normal version (using drawRect:) to work yet...



I've been a Win32 developer for quite a while.)
   2. In the program what I did was respond to mouseDrag and call  
[NSView
display]. In drawRect I draw all the scribble lines using  
[NSBezierPath

strokeLineFromPoint]
But it seems the Mac Windows Manager would automatically clean out  
the whole
drawing area. Is there a way to avoid this? Like the  
InvalidRect(HWND, 0,

FALSE) in Win32.


Your drawRect:  needs to completely draw the view, from what you  
describe it sounds like you're trying to use drawRect: to draw your  
scribbles incrementally.  That won't work, at least not like this.


Marcel

___

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: NSXMLParser frees itself on error?

2009-05-04 Thread Stephen J. Butler
On Fri, May 1, 2009 at 11:18 AM, Jesper Storm Bache jsba...@adobe.com wrote:
 I have not used NSXMLParser, but as far as I can tell from your email,
 cleanupShowParsing is called in response to a call to the parser delegate.
 In that case, you should not release the parser (because it is calling your
 delegate and is on the stack).
 Try using autorelease instead.

That could also be dangerous. What if the parser sets up its own
autorelease pool while walking the XML document? You could have a
situation like this:

- (void) parse {
  [self doSomething];

  while (notDone) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

 [delegate callbackMethod];

[pool drain];
  }

  [self doSomethingMore];
}

What you're suggesting would put the parser into the inner autorelease pool!

I still maintain that it's never safe to release/autorelease an object
from inside one of it's delegate calls. If it works at all, you're
implicitly relying on an implementation detail that's subject to
change.
___

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: NSURLConnection unhappiness

2009-05-04 Thread Jeff Johnson
Yes, those result in a message call, though it's a very fast message  
call. Within your instance methods, however, you can just access the  
ivar directly, e.g, connection without a message call and without  
self-connection.


-Jeff


On May 1, 2009, at 11:00 AM, Nick Hristov wrote:


Thank you all for your suggestions. I will use the runloop to wait on
response.

One more comment on self-ivar... I used this approach because using  
[self
connection] or self.connection (they are both the same thing) amount  
to an

extra message call.

Nick

On Thu, Apr 30, 2009 at 11:09 AM, Jeff Johnson 
publicpost...@lapcatsoftware.com wrote:


On Apr 30, 2009, at 12:53 AM, Kyle Sluder wrote:

On Thu, Apr 30, 2009 at 1:44 AM, Jeff Johnson

publicpost...@lapcatsoftware.com wrote:


On an unrelated note, your use of self-connection, etc., is
non-standard
and not advised. You should be using direct ivar access  
connection,
properties self.connection, or accessor methods [self  
connection].




Sure, `self-connection` is redundant with just plain old
`connection`, but they amount to the same thing.  Unless there's  
some

new-runtime trickery going on that I'm not aware of.

--Kyle Sluder



It amounts to the same thing, but it's a bad habit to get into. It's
redundant, as you say, for an object's own instance variables. And  
you
shouldn't be trying to directly access the instance variables of  
other
objects. According to the documentation, Marking instance  
variables @public
defeats the ability of an object to hide its data. It runs counter  
to a
fundamental principle of object-oriented programming—the  
encapsulation of
data within objects where it’s protected from view and inadvertent  
error.

Public instance variables should therefore be avoided except in
extraordinary cases. Thus, except in extraordinary cases, there's  
no reason

to use the object-ivar syntax.

-Jeff


___

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: NSURLConnection unhappiness

2009-05-04 Thread Alexander Spohr


Am 01.05.2009 um 18:00 schrieb Nick Hristov:

One more comment on self-ivar... I used this approach because using  
[self
connection] or self.connection (they are both the same thing) amount  
to an

extra message call.


Then just use ivar, without self-
It amounts to the same (no call) but looks right

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: sheets

2009-05-04 Thread Nick Zitzmann


On May 1, 2009, at 1:22 PM, Jason Todd Slack-Moehrle wrote:

Does anyone have an example for creating a 'sheet' without using  
Interface Builder at all? I just am trying to display a sheet with  
some text and an OK button and have it dismissed when pressed.



Have you tried NSBeginAlertSheet() or the NSAlert class?

Nick Zitzmann
http://www.chronosnet.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: sheets

2009-05-04 Thread Alexander Spohr

Have a look at NSAlert:

You use an NSAlert object to display an alert, either as an  
application-modal dialog or as a sheet attached to a document window.


atze


Am 01.05.2009 um 21:22 schrieb Jason Todd Slack-Moehrle:


Hi All,

Does anyone have an example for creating a 'sheet' without using  
Interface Builder at all? I just am trying to display a sheet with  
some text and an OK button and have it dismissed when pressed.


-Jason


___

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: Storing a password (iPhone)

2009-05-04 Thread Nicko van Someren

On 1 May 2009, at 04:58, Jelle De Laender wrote:

What is the best way to store a password on the iPhone?
I can't take the MD5 hash because I need to be able to work with the  
original password.


Should I create a custom class (with 2 strings) and save them with  
NSKeyedArchiver with the idea: nobody will read the files (it's  
impossible: except when you JailBreak) or what should you do?

Maybe I can simply use the NSUserDefaults?


This is exactly the sort of thing that the Key Chain is designed for.   
Take a look at the Keychain Services Programming Guide and the  
GenericKeychain example code in the iPhone SDK.


Nicko

___

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: NSOutlineView with NSImage and NSStrings

2009-05-04 Thread Corbin Dunn


On May 1, 2009, at 2:59 PM, iseecolors wrote:

I would like to have an image and a string together in my  
NSOutlineView, but it is not clear to me how to do this.  Basically  
I want to do what iTunes appears to do (icons in front of the text  
descriptors).


My initial thought was to return and NSArray that contains and  
NSImage and NSString from the method:


- (id)outlineView:(NSOutlineView *)outlineView  
objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item


But apparently the returned id is just converted to an NSString. (if  
it only deals with strings, why support id?)


Is there support for this built in to do this, or will I need to  
subclass NSOutlineView and override the drawRect method?


Look at the PhotoSearch example on the developer site.

corbin


___

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: Make connections between One Button and two different NSObjects?

2009-05-04 Thread I. Savant
  You're probably going to have to be more clear about what you want
to do. You seem to be asking a few different questions:

 can you make two connections between One Button and two different NSObjects?

  Yes. What kind of connections are you interested in? Do you instead
mean target/action connections? In that case, there is only one target
and one action for a given control.


 is it possible? to have two different IBActions go off?

  Yes. Your button could be connected to a controller (with an action
of -doTwoThings:) and that action could, in turn, call two other
actions (passing its own sender to the others).


   or some other way
 of controlling a single button from two different objects?

  Anything can send your button a message. It just has to have a
reference to it. Three thousand different controllers could have a
reference to your button (however they want to call it), and each
could message your button to 'control' it.

  ... but I don't think that's what you meant to say. You need to be
careful to learn and properly use the terminology and, above all else,
keep in mind from where / to where your messages are flowing.


 I want a normal controller,   but then i want to hide,  and unhide the
 button from the actions of a different window

  This is unclear. Try to explain *exactly* what you're trying to
accomplish and all the relevant background (like your app's setup).

--
I.S.
___

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: NSOutlineView with NSImage and NSStrings

2009-05-04 Thread Jerry Krinock


On 2009 May 01, at 14:59, iseecolors wrote:

I would like to have an image and a string together in my  
NSOutlineView, but it is not clear to me how to do this.  Basically  
I want to do what iTunes appears to do (icons in front of the text  
descriptors).


My initial thought was to return and NSArray that contains and  
NSImage and NSString from the method:


- (id)outlineView:(NSOutlineView *)outlineView  
objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item


Good guess.  Try overriding -[NSTableColumn dataCellForRow] instead,  
and returning an instance of your own custom subclass of NSCell.  This  
has been discussed more than once, as recently as within the last  
couple weeks in the list archives.


But apparently the returned id is just converted to an NSString. (if  
it only deals with strings, why support id?)


Because your table is using the default NSTextFieldCell.  Different  
cells will support different types.


You should read the document Control and Cell Programming Topics for  
Cocoa at developer.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: Question of .png and 'transparency'

2009-05-04 Thread I. Savant
On Fri, May 1, 2009 at 9:11 PM, Smith, Steven (MCP)
steven.r.sm...@hp.com wrote:

 a) should my code do the transparency for each piece so the background (say a 
 starfield) show through

 b) if not my code would the .png already be 'set' with transparency in place

 I've not done game UI befores so this is new turf for me.

  Read the documentation for NSImage and the Cocoa Drawing Guide, pay
attention to the sections discussing compositing.

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/nsimage_Class/Reference/Reference.html

http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Introduction/Introduction.html

--
I.S.
___

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 image

2009-05-04 Thread Livio Isaia

I have a custom NSButtonCell named MyButtonCell with a drawing method:

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView 
*)controlView {


   cellFrame = [self imageRectForBounds:cellFrame];
  
   [[self image] drawInRect:cellFrame fromRect:NSZeroRect 
operation:NSCompositeCopy fraction:1.0];

}

The image is well drawn... but upside down.
Can you tell why?

Thanks in advance,
regards,
livio.

___

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


UIWebView w/o the scrolling?

2009-05-04 Thread Mike Manzano
Is it possible to have a web view that doesn't scroll? I'd like to  
embed a web view in a table cell and have the table view machinery  
take care of the scrolling. The effect I'm after is for the user to  
touch a cell in a table, and have that table visually expand to show a  
rendered HTML page.



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: sheets

2009-05-04 Thread Dave Keck
Check out NSAlert, specifically +alertWithMessageText:... and
-beginSheetModalForWindow:...
___

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: NSXMLParser frees itself on error?

2009-05-04 Thread Mike Manzano
I tried doing an autorelease from the delegate and that seemed to work  
fine. Still not sure if that's entirely correct. I was under the  
impression that -parse was asynchronous, so therefore I couldn't call  
release right after it, but if it is indeed synchronous, I'll just  
stick the release there.


Thank you all for the responses!

Mike


On Apr 30, 2009, at 11:59 PM, Mike Manzano wrote:


Hi Folks,

I have an NSXMLParser doing parsing the contents of a URL. It is  
allocated like this:


_showsParser = [[NSXMLParser alloc] initWithContentsOfURL:url];

Given a good URL to a parsable XML document, its  
parserDidEndDocument: method calls this method:


- (void) cleanupShowParsing {
[_buildingShows removeAllObjects];
[_showsParser abortParsing];
[_showsParser release];
_showsParser = nil;
_currentlyBuildingShows = NO;
}

Note that the parser is aborted and released in here. This seems to  
work just fine, multiple times, with no problems. However, if I give  
it a URL to non-XML data (should be a 404 page somewhere), it calls  
parser:parseErrorOccurred: as expected. This method also calls - 
cleanupShowParsing. However, when it is called from here, the  
program eventually terminates with:


2009-04-30 23:53:52.573 Revision3[49280:20b] PARSE ERROR: Error  
Domain=NSXMLParserErrorDomain Code=5 Operation could not be  
completed. (NSXMLParserErrorDomain error 5.)
objc[49280]: FREED(id): message shouldContinueAfterFatalError sent  
to freed object=0xf305a0


I have verified that 0xf305a0 is indeed _showsParser. Further, I've  
verified that if I don't release _showsParser in - 
cleanupShowParsing, no error occurs given a non-XML file.


My question is it the case that NSXMLParser frees itself if it  
encounters an error, but does NOT free itself on a successful parse  
of a document?


Thanks!

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/mike%40instantvoodoomagic.com

This email sent to m...@instantvoodoomagic.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


Key window/first responder handling with NSDrawer containing NSTextView

2009-05-04 Thread Luke Evans
I have an NSDrawer on a window that acts as an optional 'pop out'  
editor providing a more convenient way to edit text in smaller field  
in the window's main UI.
I've used the occasional drawer before in cases where optional extra  
information/navigation is useful, and aside from one bug I know of  
with drawers and GC, I figured having an NSTextView in one would be a  
simple matter.


However...
The behaviour of key window management seems awry in my current,  
straightforward UI (more or less just as composed in Interface  
Builder).  The first time the drawer is popped open and I click in the  
text view, everything is fine, but if the I click back into some UI in  
the main window (e.g. a table row), and then click again into the  
drawer's text view to type some more text, the caret stays in the text  
view, but key events are not routed to that view.  Indeed, the table  
row that I clicked on remains fully selected and as first responder  
(highlighted blue rather than grey).


I can get the text view to take the first responder/key status again  
by clicking on the background of the drawer (not all of the drawer  
area is taken up with the text view) and have a click there assign the  
that view's window as key.  That seems to be all that is necessary,  
but clearly I want the user to simply click back in the text view to  
be able to continue to edit there.


Perhaps I could work around this by subclassing NSTextView and  
implementing a mouseDown handler that simply attempts to set the key  
window to the drawer window and/or first responder to the text view?


Any other ideas?  It seems like I'm in some corner-case that demands a  
work-around with some overt first-responder handing code, but perhaps  
it's simpler than this and I'm just overlooking something.


-- Luke


___

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: Discussion on how to draw text like that seen in toolbars

2009-05-04 Thread Dave Keck
While I'm not familiar with the original discussion, I will say that
the effect you're going for can easily be created using a shadow. If
it doesn't look right, the values you're using to create the shadow
probably need tweaking. For the recessed look, I use a shadow offset
of (0.0, 1.1) or (0.0, -1.1) (depending on whether I'm drawing in a
flipped context), which will cast the shadow at a 90 degree angle, and
with one pixel of actual shadow. Then I set the color of the shadow to
white, with an alpha of 0.75. This technique produces text that looks
nearly identical to the labels you see in toolbars.

David
___

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: NSXMLParser frees itself on error?

2009-05-04 Thread Ed Wynne


On May 3, 2009, at 5:38 PM, Kyle Sluder wrote:


Initializers must call -[self release] in case of an error.  This
means that in response to an error that occurs as part of
initialization, you must not release that object.


Initializers that call -[self release], for any reason, had also  
better return nil; (or some other valid instance).


-Ed



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: Storing a password (iPhone)

2009-05-04 Thread Sidney San Martín
You can use the iPhone's keychain (search for that term) to store passwords.

Start by taking a look at these two pages:
http://developer.apple.com/iphone/library/documentation/Security/Conceptual/keychainServConcepts/01introduction/introduction.html
http://developer.apple.com/iphone/library/documentation/Security/Reference/keychainservices/Reference/reference.html

On Fri, May 1, 2009 at 7:58 AM, Jelle De Laender
maill...@codingmammoth.com wrote:
 Hi

 What is the best way to store a password on the iPhone?
 I can't take the MD5 hash because I need to be able to work with the
 original password.

 Should I create a custom class (with 2 strings) and save them with
 NSKeyedArchiver with the idea: nobody will read the files (it's impossible:
 except when you JailBreak) or what should you do?
 Maybe I can simply use the NSUserDefaults?

 Kind regards
 Jelle
 ___

 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/s%40sidneysm.com

 This email sent to s...@sidneysm.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: Writable dir for non-admin user outside user's dir

2009-05-04 Thread Michael Ash
On Fri, May 1, 2009 at 3:28 AM, Erg Consultant erg_consult...@yahoo.com wrote:
 That's a pretty lame approach considering that Apple hides theirs.

Seems like a poor example to me, given that the path to the iTunes DRM
directory was posted right here in this very thread (albeit not
completely correct, but close enough to find it yourself).

Your user owns the system. You cannot hide things from him.

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: Integer as key in NSMutableDictionary

2009-05-04 Thread Jason Foreman

On May 4, 2009, at 2:22 AM, Weydson Lima wrote:


I am getting warnings when adding integers in the array and assigning
the integer ID as a key. The code does work though, but I am guessing
there is a better way to accomplish what I want. I know that these
methods are expecting pointers as parameters and I am passing a
scalar. So, what's the best way to approach that?


Actually, as the documentation specifies, setObject:forKey: expects an  
object that conforms to the NSCopying protocol as the key parameter.   
Keys are copied when objects are inserted.


You could use an NSNumber, e.g.:

[result setObject:... forKey:[NSNumber numberWithInt:ID]];


Jason

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: Problem with the list?

2009-05-04 Thread Alexander Spohr

Same problem here. Messages come in again since today.
But my answers are delayed as well.

atze


Am 04.05.2009 um 16:31 schrieb Robert Martin:


Hi,

I haven't received any posts for several days now, on any of the  
Apple lists I'm subscribed to...Is this a known problem, or should I  
check with my ISP?


Thanks, Rob
___

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/atze%40freeport.de

This email sent to a...@freeport.de


___

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


NSTableView, 2mln rows, looks bad.

2009-05-04 Thread Тимофей Даньшин

Hello.
I need to have a tableView with about 2 million rows, and that figure  
may actually be bigger. But the table looks awfully bad in that case:  
you get artifacts when scrolling, the text in the rows does not  
coincide with the alternate bluish and white stripes, and if you click  
on a row, you get the action from another row, not the one you see. Is  
it the problem of my design (i.e. i may have done anything wrong while  
writing that), or is it a flaw of NSTableView? Are there any  
workarounds?


Thank you in advance for your help.
Timofey.
___

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 log file for NSLog

2009-05-04 Thread Randall Meadows
I want to have a custom log file for my app, so that my client can  
send it to me when things go different.


In reading the docs for NSLog, it seems that it is just a front-end  
for asl.  So here's what I thought should work:


directories = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,  
NSUserDomainMask, YES);

NSString *logFileName = nil;
int result = 0;
if ([directories count]  0) {
   logFileName = [directories objectAtIndex:0];
   logFileName = [logFileName stringByAppendingPathComponent:@Logs];
   if ([fileMgr createDirectoryAtPath:logFileName  
withIntermediateDirectories:YES attributes:nil error:nil]) {
  logFileName = [logFileName  
stringByAppendingPathComponent:@MyLogFile.log];
  int fd = open([logFileName fileSystemRepresentation], (O_RDWR| 
O_CREAT|O_TRUNC), (S_IRWXU|S_IRWXG|S_IRWXO));

  if (fd != -1) {
 result = asl_add_log_file(NULL, fd);
  }
   }
}

This results in the file being created, but nothing ever being written  
to it.  In Console.app, I can see the messages when I select All  
Messages, Console Messages, and system.log, but *not*  
MyLogFile.log.


I assume it has something to do with this comment in the docs for  
NSLogv (which NSLog calls): If the STDERR_FILENO file descriptor has  
been redirected away from the default or is going to a tty, it will  
also be written there. If you want to direct output elsewhere, you  
need to use a custom logging facility.  This seems contradictory to  
the statement that NSLog Logs an error message to the Apple System  
Log facility.  If anyone would like to educate me on my obvious  
misunderstanding of this, I'd appreciate it.


Anyway, I tried it, and yes, redirecting stderr to my log file does  
put all my NSLogs into my log file.  But, it also prevents the  
messages from being seen in Xcode's Console window.


How can I have my cake and eat it too?


randy
___

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: How to change the case of letters

2009-05-04 Thread Тимофей Даньшин
It looks like, if you want to change the case of a particular letter  
(say, all occurrences, letter a), you will have to iterate through  
all the chars in your textView, check if they are as, if they are  
upper or lower case, and change their case accordingly.

That is, if I understood your intentions correctly.

On May 4, 2009, at 2:38 PM, rethish wrote:


Hi,

I am using the action methods uppercaseWord: and lowercaseWord: to  
change

the case of selected word.

-(IBAction)changecase:(id)sender
{
  if([[fontCasePopup titleOfSelectedItem] isEqualToString:@A])
   {
  [textView uppercaseWord:sender];
   }
   else if([[fontCasePopup titleOfSelectedItem] isEqualToString:@a])
   {
[textView lowercaseWord:sender];
   }
}

I want to change the case of letters rather than a complete word.  
And I

tried it with another action message:

[textView changeCaseOfLetter:sender];

But its not working. why is it so? Is there anything thing to be done?


Thank you in advance

rethish




___

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/ok5.admin%40gmail.com

This email sent to ok5.ad...@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: Why is -makeWindowControllers getting called twice?

2009-05-04 Thread Kyle Sluder
Note these two lines:

On Sun, May 3, 2009 at 9:38 PM, David Scheidt dsche...@panix.com wrote:
 #0  -[MyDocument makeWindowControllers] (self=0x10471d0, _cmd=0x9464d69c) at
 #0  -[MyDocument makeWindowControllers] (self=0x105d5b0, _cmd=0x9464d69c) at

The self pointers are different (0x10471d0 vs. 0x105d5b0): you have
two MyDocument instances, and -makeWindowControllers is being called
on each instance.  My guess is that you've accidentally added an
instance of MyDocument to your nib.

--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: Integer as key in NSMutableDictionary

2009-05-04 Thread Nick Zitzmann


On May 4, 2009, at 1:22 AM, Weydson Lima wrote:


I am getting warnings when adding integers in the array and assigning
the integer ID as a key. The code does work though, but I am guessing
there is a better way to accomplish what I want. I know that these
methods are expecting pointers as parameters and I am passing a
scalar. So, what's the best way to approach that?



NSIntegers are C primitives, not ObjC objects. You need to wrap them  
in NSNumber objects using +numberWithInteger: in order to use them the  
way you're trying to use them.


Nick Zitzmann
http://www.chronosnet.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 a NSHTTPCookie

2009-05-04 Thread Nick Zitzmann


On May 4, 2009, at 12:58 AM, Chris wrote:

When I try to set the newly created cookie to the  
sharedHTTPCookieStorage it doesn't ever get set. Am I doing  
something wrong?



Possibly. From the -setCookie: documentation:

This method will accept the cookie only if the receiver’s cookie  
accept policy is NSHTTPCookieAcceptPolicyAlways or  
NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain. The cookie will be  
ignored if the receiver’s cookie accept policy is  
NSHTTPCookieAcceptPolicyNever.


Nick Zitzmann
http://www.chronosnet.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: Why is -makeWindowControllers getting called twice?

2009-05-04 Thread Tommy Nordgren

Are the listing from two different GDB sessions?
Otherwise, judging from the value of self in [MyDocument  
makeWindowControllers],

you have TWO instances of the MyDocument class. Is this intentional?
On May 4, 2009, at 3:38 AM, David Scheidt wrote:

I'm trying to figure out why my NSPersistantDocuement subclass's - 
makeWindowControllers is getting called twice.  I'm also trying to  
figure out why a nib that I'm trying to load from a viewcontroller  
created by the window controller made by -makeWindowController isn't  
loading.  I'm willing to bet they're related.  I'm further willing  
to bet it's something I've done, but I'm stumped.


Some relevant bits of GDB:

gdb) where
#0  -[MyDocument makeWindowControllers] (self=0x10471d0,  
_cmd=0x9464d69c) at /./MyDocument.m:84
#1  0x946e8e02 in -[NSDocumentController  
openUntitledDocumentAndDisplay:error:] ()

#2  0x946e895f in -[NSDocumentController(NSInternal) _openUntitled] ()
#3  0x946e87b1 in -[NSApplication _doOpenUntitled] ()
#4  0x946e7e95 in -[NSApplication(NSAppleEventHandling)  
_handleAEOpen:] ()
#5  0x946e76bc in -[NSApplication(NSAppleEventHandling)  
_handleCoreEvent:withReplyEvent:] ()
#6  0x912ee43f in -[NSAppleEventManager  
dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()

#7  0x912ee14f in _NSAppleEventManagerGenericHandler ()
#8  0x95bb4648 in aeDispatchAppleEvent ()
#9  0x95bb457e in dispatchEventAndSendReply ()
#10 0x95bb4425 in aeProcessAppleEvent ()
#11 0x917279a5 in AEProcessAppleEvent ()
#12 0x946e4f91 in _DPSNextEvent ()
#13 0x946e4630 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] ()

#14 0x946dd66b in -[NSApplication run] ()
#15 0x946aa8a4 in NSApplicationMain ()
#16 0x2eee in main (argc=1, argv=0xb7e4) at /Users/dms/ 
Documents/w/main.m:13

(gdb) go
Undefined command: go.  Try help.
(gdb) cont
Continuing.
(gdb) continue
2009-05-03 21:31:04.429 mwa3[61892:813] MANAgedobjectContext is  
NSManagedObjectContext: 0x104b220

(gdb) continue
(gdb) continue
2009-05-03 21:31:08.161 mwa3[61892:813] Cannot create NSSet from  
object BottlesDetailViewController: 0x104c470 of class  
BottlesDetailViewController

(gdb) where
#0  -[MyDocument makeWindowControllers] (self=0x105d5b0,  
_cmd=0x9464d69c) at /Users/dms/Documents/wine/mwa3-view/MyDocument.m: 
84
#1  0x946e8e02 in -[NSDocumentController  
openUntitledDocumentAndDisplay:error:] ()

#2  0x946e895f in -[NSDocumentController(NSInternal) _openUntitled] ()
#3  0x946e87b1 in -[NSApplication _doOpenUntitled] ()
#4  0x946e7e95 in -[NSApplication(NSAppleEventHandling)  
_handleAEOpen:] ()
#5  0x946e76bc in -[NSApplication(NSAppleEventHandling)  
_handleCoreEvent:withReplyEvent:] ()
#6  0x912ee43f in -[NSAppleEventManager  
dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()

#7  0x912ee14f in _NSAppleEventManagerGenericHandler ()
#8  0x9138459c in _NSAppleEventManagerPreDispatchHandler ()
#9  0x95bb4648 in aeDispatchAppleEvent ()
#10 0x95bb457e in dispatchEventAndSendReply ()
#11 0x95bb4425 in aeProcessAppleEvent ()
#12 0x917279a5 in AEProcessAppleEvent ()
#13 0x946e4f91 in _DPSNextEvent ()
#14 0x946e4630 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] ()

#15 0x946dd66b in -[NSApplication run] ()
#16 0x946aa8a4 in NSApplicationMain ()
#17 0x2eee in main (argc=1, argv=0xb7e4) at /Users/dms/ 
Documents/wine/mwa3-view/main.m:13

___

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/tommy.nordgren%40comhem.se

This email sent to tommy.nordg...@comhem.se


---
See the amazing new SF reel: Invasion of the man eating cucumbers from  
outer space.
On congratulations for a fantastic parody, the producer replies :  
What parody?


Tommy Nordgren
tommy.nordg...@comhem.se



___

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: NSXMLParser frees itself on error?

2009-05-04 Thread Sean McBride
On 5/3/09 5:38 PM, Kyle Sluder said:

Initializers must call -[self release] in case of an error.  This
means that in response to an error that occurs as part of
initialization, you must not release that object.

Actually, they should call [super dealloc] not [self release], see:

http://lists.apple.com/archives/Objc-language/2008/Sep/msg00133.html

--

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: NSXMLParser frees itself on error?

2009-05-04 Thread Kyle Sluder
On Mon, May 4, 2009 at 5:05 PM, Sean McBride s...@rogue-research.com wrote:
 Actually, they should call [super dealloc] not [self release], see:

You're right.  Brain fart.

--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: Discussion on how to draw text like that seen in toolbars

2009-05-04 Thread Jean-Daniel Dupas


Le 2 mai 09 à 00:42, Alex Kac a écrit :

I know there was a discussion about this a few months ago on this  
list, but I cannot find the right terms to search for. The  
discussion was how to draw text so that it was sunken much like you  
see in the toolbar. I just remember there was a specific way  
recommended to do it and I can't find it. Drawing the text twice is  
more of a shadow effect, so I don't think that was it...




the -[NSCell setBackgroundStyle:] method is the key.

[[myTextField cell] setBackgroundStyle:NSBackgroundStyleRaised];


___

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: question about mutable vs. non-mutable

2009-05-04 Thread Kyle Sluder
On Fri, May 1, 2009 at 4:54 PM, Erik Buck erik.b...@sbcglobal.net wrote:
 There is nothing to add now (13 years later):

That's a bit bold, isn't it?  Sure, the primitives and research might
not have changed all that much, but the technology sure has.  We now
have GPGPU and the prospect of manycore Larabee, both thrusting
parallel processing into the forefront.  Immutability is a very
important topic when dealing with writing programs that are ready to
take advantage of these technologies.

--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: NSURLConnection unhappiness

2009-05-04 Thread Kyle Sluder
On Fri, May 1, 2009 at 12:00 PM, Nick Hristov n...@freshlybakedapps.com wrote:
 One more comment on self-ivar... I used this approach because using [self
 connection] or self.connection (they are both the same thing) amount to an
 extra message call.

This is true, and sometimes you want to do this, while other times you
don't.  But anywhere you do self-foo you can simply do foo, assuming
foo isn't shadowed by another variable identifier in the same scope.
Properties, methods, and variables (including ivars) all exist in
separate namespaces.

--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: Key window/first responder handling with NSDrawer containing NSTextView

2009-05-04 Thread Luke Evans

Further to this...

The workaround of subclassing NSTextView, and having a mouse down  
event set push the first responder to itself, seems to work OK.
It's a rather annoying/plaltry reason to have to subclass however.  I  
still wonder if I'm looking at a bug, or some lack of education on my  
part regarding how you would have the drawer window and its content  
automatically take the first responder status when clicked  
(particularly the NSTextView).


Perhaps someone has experience here and can comment on a better way to  
get this working, without the subclassing.


-- Luke


On 4-May-09, at 12:57 PM, Luke Evans wrote:

I have an NSDrawer on a window that acts as an optional 'pop out'  
editor providing a more convenient way to edit text in smaller field  
in the window's main UI.
I've used the occasional drawer before in cases where optional extra  
information/navigation is useful, and aside from one bug I know of  
with drawers and GC, I figured having an NSTextView in one would be  
a simple matter.


However...
The behaviour of key window management seems awry in my current,  
straightforward UI (more or less just as composed in Interface  
Builder).  The first time the drawer is popped open and I click in  
the text view, everything is fine, but if the I click back into some  
UI in the main window (e.g. a table row), and then click again into  
the drawer's text view to type some more text, the caret stays in  
the text view, but key events are not routed to that view.  Indeed,  
the table row that I clicked on remains fully selected and as first  
responder (highlighted blue rather than grey).


I can get the text view to take the first responder/key status again  
by clicking on the background of the drawer (not all of the drawer  
area is taken up with the text view) and have a click there assign  
the that view's window as key.  That seems to be all that is  
necessary, but clearly I want the user to simply click back in the  
text view to be able to continue to edit there.


Perhaps I could work around this by subclassing NSTextView and  
implementing a mouseDown handler that simply attempts to set the key  
window to the drawer window and/or first responder to the text view?


Any other ideas?  It seems like I'm in some corner-case that demands  
a work-around with some overt first-responder handing code, but  
perhaps it's simpler than this and I'm just overlooking something.


-- Luke




___

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: Programmatically Changing Display(s) to Greyscale

2009-05-04 Thread Jean-Daniel Dupas


Le 4 mai 09 à 19:23, Grant Erickson a écrit :

While the Displays preference pane doesn't appear to allow it, the  
Universal

Access preference pane allows setting all active, online displays to
greyscale mode.

However, when using CGDisplayAvailableModes, the only modes that  
appear for
the current display width and height are 8-bit, 16-bit and 32-bit  
RGB modes

(3 samples per pixel).

Is there a Cocoa, CoreGraphics or other ApplicationServices API that  
handles

this mode selection or does this use an IOKit COM API? Given that
CGDisplayCurrentMode displays 32-bits, 3 samples per pixel even when
Universal Access is putting the displays in greyscale mode seems to  
hint at

the latter.

Regards,

Grant


I don't know any public function to do this, but the pref pane uses  
theses privates functions:


extern Boolean CGDisplayUsesForceToGray();
extern void CGDisplayForceToGray(Boolean gray);

Fill a feature request if you want them to be public in a futur 
release.___

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: Discussion on how to draw text like that seen in toolbars

2009-05-04 Thread Brandon Walkin

[yourTextFieldCell setBackgroundStyle:NSBackgroundStyleRaised];

This method was introduced in 10.5. If you require Tiger  
compatibility, you can use NSShadow but you'll be losing subpixel  
antialiasing.


Alternately, you can use BWInsetTextField which is part of the  
BWToolkit IB plugin: http://brandonwalkin.com/bwtoolkit/


-Brandon


On 1-May-09, at 6:42 PM, Alex Kac wrote:

I know there was a discussion about this a few months ago on this  
list, but I cannot find the right terms to search for. The  
discussion was how to draw text so that it was sunken much like you  
see in the toolbar. I just remember there was a specific way  
recommended to do it and I can't find it. Drawing the text twice is  
more of a shadow effect, so I don't think that was it...


Alex Kac - President and Founder
Web Information Solutions, Inc.

Patience is the companion of wisdom.
--Anonymous




___

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/bwalkin%40gmail.com

This email sent to bwal...@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: NSXMLParser frees itself on error?

2009-05-04 Thread Jesper Storm Bache

Hi Stephen,
I agree with you, deleting the owner of a delegate from a delegate  
callback (either directly, or though an auto-release pool) is not a  
good practice.
Lifetime should be managed on the outside of the parser (after parse  
returns).


Jesper


On May 4, 2009, at 11:31 AM, Stephen J. Butler wrote:

On Fri, May 1, 2009 at 11:18 AM, Jesper Storm Bache  
jsba...@adobe.com wrote:
I have not used NSXMLParser, but as far as I can tell from your  
email,
cleanupShowParsing is called in response to a call to the parser  
delegate.
In that case, you should not release the parser (because it is  
calling your

delegate and is on the stack).
Try using autorelease instead.


That could also be dangerous. What if the parser sets up its own
autorelease pool while walking the XML document? You could have a
situation like this:

- (void) parse {
 [self doSomething];

 while (notDone) {
   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

[delegate callbackMethod];

   [pool drain];
 }

 [self doSomethingMore];
}

What you're suggesting would put the parser into the inner  
autorelease pool!


I still maintain that it's never safe to release/autorelease an object
from inside one of it's delegate calls. If it works at all, you're
implicitly relying on an implementation detail that's subject to
change.
___

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/jsbache%40adobe.com

This email sent to jsba...@adobe.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


NSImage drawing

2009-05-04 Thread Livio Isaia

I have a custom NSButtonCell named MyButtonCell with a drawing method:

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView 
*)controlView {


  cellFrame = [self imageRectForBounds:cellFrame];
[[self image] drawInRect:cellFrame fromRect:NSZeroRect 
operation:NSCompositeCopy fraction:1.0];

}

The image is well drawn... but upside down.
Can you tell why?

Thanks in advance,
regards,
livio.


___

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, or threading?

2009-05-04 Thread James Maxwell


Thanks for this. I actually found your page while googling around for  
help. I'll check it out now.


Cheers,

J.

Sent from my iPod

On 26-Apr-09, at 12:29 PM, Richard Frith-Macdonald rich...@tiptree.demon.co.uk 
 wrote:




On 26 Apr 2009, at 18:39, James Maxwell wrote:


So, how can I put my dataThing into some process, thread, etc., in  
a way that keeps it totally in its own world, so to speak?


There is a simple an easy way to keep it in a separate thread ... so  
that's probably what you want to do.
You would use 'Distributed Objects' (the NSConnection class) to  
communicate between the main thread and the dataThing thread.


The way it works is as follows:

1. your code creates a pair of NSPort objects to talk to each other.
2. it launches a second thread, and in that thread creates a server  
NSConnection using those ports, and registers your dataThing object  
as the server object for the NSConnection
3. in the main thread another (client) NSConnection is created using  
the same two ports, and you ask the client connection for its 'root  
object'


From then on, the main thread sends messages to the 'root object' of  
the connection exactly as if it was sending them directly to the  
dataThing object, and the NSConnection code manages things for you  
so you don't have to worry about locking.


There's an example of this sort of thing at 
http://lachand.free.fr/cocoa/Threads.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


  1   2   >