Re: Instruments and leaks in a DRM framework

2011-05-03 Thread Wim Lewis

On May 1, 2011, at 3:42 AM, Jose R.P. - Renacentist Software wrote:
> I've run "Instruments" in order to detect leaks in a sample xcodeproj 
> (RTestApp) for the framework I'm creating. There are leaks and the tool never 
> identifies my Framework as the responsible one, but there are at least fifty 
> "Foundation" (substringWithRange:) and "libcrypto" (CRYPTO_malloc) leaks.
> 
> Is this result reliable? I mean, I don't want to be fooled by Instruments 
> into believing that I'm not the responsible of the leaks.


Instruments (or malloc_history or any of the similar tools) will tell you where 
the object was allocated, but that doesn't always tell you who should have 
freed it. For example, if you have code like this

NSString *blah = [otherString substringWIthRange: ... ];
[blah retain];
...
// never getting around to releasing it

will show the source of the leaked string as -substringWIthRange:, but the bug 
is in your code.

Most of the time the culprit is visible somewhere in the call stack above the 
malloc event that Instruments finds; that's why it records the call stack for 
you. In more complicated situations you may have to trace through multiple 
retains, releases, autoreleases, and the like to find the unbalanced call.


___

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: Enable a button once text is added to textfield

2011-05-03 Thread Kyle Sluder
On May 3, 2011, at 9:10 AM, Eric Williams  wrote:

> Any suggestions on how I can bind a button to a textfield so that the button 
> is disabled when the field is empty, and then enabled once text has been 
> entered in the field?

The typical MVC approach would be to bind your buttons enabled binding to a key 
on a controller object that, in turn, reflects the state of your text field.

Remember, the controller is where everything meets.

--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: Error in documentation: Cocoa Drawning Guide

2011-05-03 Thread Roland King
At the bottom of the docs page is a "did this help" set of links. That leads 
you to a place you can file documentation comments 

On May 4, 2011, at 13:51, Дмитрий Николаев  wrote:

> Hello!
> 
> I dont know where to post such errors. 
> In 
> http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaDrawingGuide/Paths/Paths.html
> 
> Paths. 
> Line Dash Style
> 
> 
> Listing 5-5  Adding a dash style to a path
> 
> // Set the line dash pattern.
>float lineDash[6];
> 
> float need to be replaced with 
> CGFloat___
> 
> 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/rols%40rols.org
> 
> This email sent to r...@rols.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


Error in documentation: Cocoa Drawning Guide

2011-05-03 Thread Дмитрий Николаев
Hello!

I dont know where to post such errors. 
In 
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaDrawingGuide/Paths/Paths.html

Paths. 
Line Dash Style


Listing 5-5  Adding a dash style to a path

// Set the line dash pattern.
float lineDash[6];

float need to be replaced with 
CGFloat___

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


Enable a button once text is added to textfield

2011-05-03 Thread Eric Williams
Any suggestions on how I can bind a button to a textfield so that the button is 
disabled when the field is empty, and then enabled once text has been entered 
in the field?

Thanks. 


Eric Williams
AIM & Email: wile...@gmail.com
Skype: wilersh




___

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: Vertical alignment in NSTextView

2011-05-03 Thread Andrew Glushchenko
Hello, Rimas

You can change the inset of the NSTextContainer associated with the
NSTextView for this purpose. See setTextContainerInset method of NSTextView.

2011/5/3 Rimas M. 

> Hello,
>
> I continue my fight with cocoa text system :)) At the moment I am loosing..
>
> Now I am trying to implement vertical text alignment in NSTextView. If
> I would need only drawing, would be quite easy. But I need to maintain
> an editing capability.
>
> The thing I am talking about is very similar (or even the same) to the
> text writing inside shape (rectangle) using Keynote: insert rectangle
> shape, double click it ant write some text. Using inspector (Text tab)
> you can choose between top, middle and bottom vertical alignment.
>
> I am almost sure, that I need to subclass and overwrite some stuff
> from either NSLayoutManager or NSATSTypesetter. Just not sure which
> exact... Any thoughts?
>
> Best Regards,
>
> Rimas M.
> ___
>
> 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/nosetinker%40gmail.com
>
> This email sent to nosetin...@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


Have links in the cocoa application which sent action to my controller

2011-05-03 Thread visco
Hi All

Usually for sending actions to controller, I use NSButton. But is there
anyway I can use a text to send action to a controller(not as a hyperlink to
a website) when it is clicked just like that on a button.

-- 
thanks and regards
visco
___

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


Instruments and leaks in a DRM framework

2011-05-03 Thread Jose R.P. - Renacentist Software
i devs,

I've run "Instruments" in order to detect leaks in a sample xcodeproj 
(RTestApp) for the framework I'm creating. There are leaks and the tool never 
identifies my Framework as the responsible one, but there are at least fifty 
"Foundation" (substringWithRange:) and "libcrypto" (CRYPTO_malloc) leaks.

Is this result reliable? I mean, I don't want to be fooled by Instruments into 
believing that I'm not the responsible of the leaks.

This is my project:
http://www.renacentist.com/swupdates/Renascent_Framework_Manual.pdf
http://www.renacentist.com/index.php/products/mmacsoften/renascenten
(Activation/registration/DRM/payment/licensing for apps/bundles packed in a 
Cocoa Framework)

Cheers,
Jose

PD: 
If anyone is interested in becoming a beta tester, please, don't hesitate to 
contact me.


Jose R.P. - Renacentist Software
j...@renacentist.com
Tweeter: @renacentist





___

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


Issues regarding NSTextStorage

2011-05-03 Thread Vadim Lozko
I've originally posted this on the dev forums but after a few days it's
only gotten 8 views and no replies. I'm hoping for a bit more luck here.
Here's the original post:

We use a subclass of NSTextStorage that enables us to do live word and
page count. The final product, however, must be written out in MS Word
format. Currently there are two versions (which we plan to merge into one
eventually) in which version a doesn't exhibit the problem and version b
does. We could end up just being lucky as to why version a doesn't as the
failure rate is about 6%. The problem is that whenever we export out the
file in a Doc format, it will on occasion not reopen as either an
NSAttributedString or even in Word. When attempting to recover the file in
Word 2008, there is some extra stuff added to the end of the document that
appears to relate to formatting. Specifically, we get this:
 
Normal
Normal
Default Paragraph Font
Default Paragraph Font
Times New Roman
Times New Roman
Symbol
Symbol
Helvetica
Helvetica
Root Entry
1Table
1Table
WordDocument
WordDocument
SummaryInformation
SummaryInformation
DocumentSummaryInformation
DocumentSummaryInformation

I'm assuming this is the font/formatting table similar to how an RTF
document is formatted.

 
The major difference between version a and b is that version b has the
ability to insert a page break. The code to do it is:

[[self firstTextView] insertContainerBreak:nil];

I've tried run various test to see if container breaks are the cause of
the corruption but I haven't been able to duplicate it. This is the header
and implementation of our subclassed text storage:

 
@interface SESTextStorage : NSTextStorage
{
 NSMutableAttributedString *text;
 NSUInteger wordCount;
 NSCharacterSet* lettersAndNumbers;
}

- (id)initWithAttributedString:(NSAttributedString *)aString
wordCount:(unsigned)wc;
- (NSData *)wordDocumentFromText;

@property (readonly) NSUInteger wordCount;

@end

---

#import "SESConstants.h"
#import "SESTextStorage.h"


@implementation SESTextStorage

- (NSUInteger)wordCountForRange:(NSRange)range
{
 NSUInteger wc = 0;
 int index = range.location;
 while (index < NSMaxRange(range))
 {
  int newIndex = [self nextWordFromIndex:index forward:YES];
  NSString *word = [[self string]
substringWithRange:NSMakeRange(index, newIndex-index)];
  if ([word rangeOfCharacterFromSet:lettersAndNumbers].location !=
NSNotFound)
{
   wc++;
  }
  index = newIndex;
 }
 return wc;
}

- (NSRange)wordRangeForCharRange:(NSRange)charRange
{
 NSRange wordRange;
 wordRange.location = [self nextWordFromIndex:charRange.location
forward:NO];
 wordRange.length = [self nextWordFromIndex:NSMaxRange(charRange)
forward:YES] - wordRange.location;
 return wordRange;
}

- (NSUInteger)wordCount
{
 return wordCount;
}

#pragma mark -
#pragma mark NSTextStorage Overrides

- (id)init
{
 if (nil != (self = [super init]))
 {
  text = [[NSMutableAttributedString alloc] init];
lettersAndNumbers = [[NSCharacterSet
alphanumericCharacterSet] retain];
  wordCount = 0;
 }
 return self;
}

- (id)initWithAttributedString:(NSAttributedString *)aString
{
 if (nil != (self = [super init]))
 {
  text = [aString mutableCopy];
  wordCount = [self wordCountForRange:NSMakeRange(0,[text
length])];
 }
 return self;
}

- (id)initWithAttributedString:(NSAttributedString *)aString
wordCount:(unsigned)wc
{
 if (nil != (self = [super init]))
 {
  text = [aString mutableCopy];
  wordCount = wc;
 }
 return self;
}

- (void)dealloc
{
 [[NSNotificationCenter defaultCenter] removeObserver:self];
[lettersAndNumbers release];
 [text release];
 [super dealloc];
}

- (NSString *)string
{
 return [text string];
}

- (NSDictionary *)attributesAtIndex:(NSUInteger)index
effectiveRange:(NSRangePointer)aRange
{
 return [text attributesAtIndex:index effectiveRange:aRange];
}

- (void)replaceCharactersInRange:(NSRange)aRange withString:(NSString
*)aString
{ 
 int strlen = [aString length];
 NSRange wcRange = [self wordRangeForCharRange:aRange];
 wordCount -= [self wordCountForRange:wcRange];
 NSRange changedRange = NSMakeRange(wcRange.location, (wcRange.length
- aRange.length) + strlen);
 [text replaceCharactersInRange:aRange withString:aString];
 int lengthChange = strlen - aRange.length;
 [self edited:NSTextStorageEditedCharacters range:aRange
changeInLength:lengthChange];
 wordCount += [self wordCountForRange:changedRange];
 [[NSNotificationCenter defaultCenter]
postNotificationName:SESTextStorageStatisticsDidChangeNotification
object:self];
}

- (void)setAttributes:(NSDictionary *)attributes range:(NSRange)aRange
{
 [text setAttributes:attributes range:aRange];
 [self edited:NSTextStorageEditedAttribute

Interruption of NSTreeController's selectionIndexPaths updating after mouseDown

2011-05-03 Thread Kirill K
Hello,

Problem Background:

I have a NSOutlineView with every tableColumn binded programmatically
to the NSTreeController's arrangedObjects so there is no need to bind
selectionIndexPaths. The source of NSTreeController's arrangedObjects
is a mutableArray. I'm adding all nodes to the NSTreeController
dynamically by performing - (void)insertObject:(id)object
atArrangedObjectIndexPath:(NSIndexPath *)indexPath; on main thread. I
have overridden NSOutlineView's mouseDown event in the way like:
- (void)mouseDown:(NSEvent *)event
{ /*...myMethods...*/
[super mouseDown:event];}

The Problem:

When the nodes are being added very fast and I perform the mouseDown
event on the outlineView, then very often the next situation takes
place:

the thread that adds nodes to TreeController interrupts the sequence
(I guess) called by mouseDown event so insertObject:
atArrangedObjectIndexPath: is called before
thensetSelectionIndexPaths:. That's why the new selection in
outlineView disappears and treeController still has the old version of
selectedIndexPaths.

I've tried one partial solution: blocked my insertObject: method
(with@synthesized(outlineView)) so that it couldn't change the entire
of outlineView, but it often rises in thread conflict and app freezes.

Are there any ideas how to solve the problem with disappearing selections?

Regards,
Kirill
___

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: onSocketDidDisconnect in CocoaAsyncSocket

2011-05-03 Thread Bing Li
Dear Patrick,

Thanks so much for your answer!

I don't know the details of TCP. However, TCP should be a reliable protocol.
Developers are not required to keep its connection state since TCP does
that. That's one of the important differences between TCP and UDP, right?
When using UDP, it is mandatory to keep the connection by developers
themselves. Am I right?

According to my experiences, when a TCP connection is disconnected without
calling the relevant closing method, an exception should be thrown in the
counterpart side. Do you think so? A heartbeat you mentioned should be
handled by TCP not programmers.

Best regards,
Bing

On Wed, May 4, 2011 at 2:08 AM, Patrick Mau  wrote:

> Hallo Bing
>
> I saw your message and thought I share my ideas. Maybe it's of some use to
> you.
>
> TCP/IP is a state machine, meaning it can only react to state changes on a
> connection.
>
> When you kill a connected client, no packet is transmitted to your server
> anymore.
> That means that it has not received a FIN packet that would indicate your
> client
> has been killed.
>
> Your server will only know about your terminated client by the time it
> reads or writes
> to the socket, because it will no longer receive an ACK for these packets.
>
> That's where timeouts come into play. If you install some kind of timer
> that would fire
> after a certain time of inactivity, your server itself should close the
> connection.
>
> It will then timeout waiting for the ACK that it is waiting for in response
> to the
> FIN packet it has tried to send.
>
> That's all based on on my BSD socket programming knowlegde, I've not used
> the CocoaAsyncSocket API myself.
>
> I hope it gives you some idea.
> Patrick
>
> On 02.Mai.2011, at 18:16, Bing Li wrote:
>
> > Dear all,
> >
> > Can anyone answer this question?
> >
> > Thanks so much!
> > Bing
> >
> > On Fri, Apr 29, 2011 at 7:21 PM, Bing Li  wrote:
> >
> >> Dear Michael,
> >>
> >> "Disgracefully" means the client does not close normally. It might be
> >> crashed or closed by killing the relevant thread or process. I did that
> by
> >> clicking the red Tasks button in XCode. In this situation, the
> connection
> >> must not be closed properly with the socket methods.
> >>
> >> According to my test, [AsyncSocketDelegate onSocket:
> >> willDisconnectWithError:] is not called either.
> >>
> >> I got the sample code from
> >> http://www.macresearch.org/cocoa-scientists-part-xxix-message. I am
> still
> >> a new developer. I am not sure if the code has any problems.
> >>
> >> Thanks so much for your help!
> >>
> >> Best regards,
> >> BIng
> >>
> >>
> >> On Fri, Apr 29, 2011 at 6:56 AM, Michael Dautermann  >wrote:
> >>
> 
>  I started to use CocoaAsyncSocket to establish TCP connections among
> >>> iPads.
> 
>  I got a problem. According to the references (
>  http://code.google.com/p/cocoaasyncsocket/wiki/Reference_AsyncSocket
> ),
>  onSocketDidDisconnect would be invoked immediately if the connection
> is
> >>> not
>  already disconnected. I felt confused. What does "not already
> >>> disconnected"
>  mean? I think onSocketDidDisconnect should be called when a connection
> >>> is
>  disconnected. The description in the reference is wrong?
> 
>  I implemented a server and a client using CocoaAsyncSocket. When
> closing
> >>> the
>  client disgracefully, I noticed that onSocketDidDisconnect was NOT
> >>> called.
>  Anything wrong with it?
> >>>
> >>> Here are some questions that might help get some further context:
> >>>
> >>> how are you closing the client "disgracefully"?
> >>>
> >>> did the companion [AsyncSocketDelegate onSocket:
> willDisconnectWithError:]
> >>> method get called?
> >>>
> >>> did you properly set your delegate and define that your object (the one
> >>> that holds your delegate methods) conforms to the delegate protocol in
> it's
> >>> .h file?
> >>>
> >>>
> >>>
> >>
> > ___
> >
> > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> >
> > Please do not post admin requests or moderator comments to the list.
> > Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> >
> > Help/Unsubscribe/Update your Subscription:
> >
> http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40mail.c2am.de
> >
> > This email sent to cocoa-...@mail.c2am.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: @selector signature with two colons instead of actual message name

2011-05-03 Thread David Reed

On May 3, 2011, at 9:52 PM, Stephen J. Butler wrote:

> On Tue, May 3, 2011 at 8:49 PM,   wrote:
>> - (void)noEmailAlertDidEnd:(NSAlert*) returnCode:(NSInteger)retCode 
>> contextInfo:(void*)ctxInfo {
> 
> See it now?
> 
> - (void)noEmailAlertDidEnd:(NSAlert*) returnCode
>  :(NSInteger)retCode
>  contextInfo:(void*)ctxInfo
> 
> It's using 'returnCode' as the first variable to the message
> (NSAlert*). And then it sees 'retCode' as a variable without a
> parameter name.

D'oh. I knew I had to be doing something stupid. I don't know how I missed that.

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: @selector signature with two colons instead of actual message name

2011-05-03 Thread Stephen J. Butler
On Tue, May 3, 2011 at 8:49 PM,   wrote:
> - (void)noEmailAlertDidEnd:(NSAlert*) returnCode:(NSInteger)retCode 
> contextInfo:(void*)ctxInfo {

See it now?

- (void)noEmailAlertDidEnd:(NSAlert*) returnCode
  :(NSInteger)retCode
  contextInfo:(void*)ctxInfo

It's using 'returnCode' as the first variable to the message
(NSAlert*). And then it sees 'retCode' as a variable without a
parameter name.
___

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


@selector signature with two colons instead of actual message name

2011-05-03 Thread davelist

I create a sheet using the following:

 [alert beginSheetModalForWindow:[self windowForSheet] modalDelegate:self 
didEndSelector:@selector(noEmailAlertDidEnd::contextInfo:) contextInfo:NULL];

What looks strange to me is the @selector(noEmailAlertDidEnd::contextInfo:) 
that got created by Xcode's code completion. The signature of the method is:

- (void)noEmailAlertDidEnd:(NSAlert*) returnCode:(NSInteger)retCode 
contextInfo:(void*)ctxInfo {

So why does code completion put two colons in a row instead of returnCode: and 
if I insert returnCode: in the @selector I get an unrecognized selector 
exception when I run it. It does work fine with the two colons in a row. What 
am I missing as I don't understand why it works with the two colons and why it 
does not work with the returnCode:?

This is on 10.6.7 using Xcode 4.0.2

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: Quick Looking big files crash

2011-05-03 Thread Brad Stone
Interesting, OK, now remember, t this is new to me.

To begin the QL panel I run this required method:
- (void)beginPreviewPanelControl:(QLPreviewPanel *)panel
{
previewPanel = [panel retain];
panel.delegate = self;
panel.dataSource = self;
}
 
and then it ends with 

- (void)endPreviewPanelControl:(QLPreviewPanel *)panel
{
[previewPanel release];
previewPanel = nil;
}

Where QLPreviewPanel* previewPanel; is defined in my header file.

The crash happens after the begin and never gets to the end.  

I see here 
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcCoreFoundation.html
 that to "ensure the longevity of Objective-C objects, you should use CFRetain 
instead of retain".  

I haven't been able to find the correct syntax to replace the retain/release 
with CFRetain/CFRelease

On May 3, 2011, at 7:51 PM, Wim Lewis wrote:

> 
> On 3 May 2011, at 4:03 PM, Brad Stone wrote:
>> I have a symbolic breakpoint set and it stops on 
>> auto_refcount_underflow_error, even the small files.  If I continue the doc 
>> shows in QL.
> 
> Presumably, a few stack frames up, there will be a call to CFRelease() which 
> is causing the underflow (what would be an over-released zombie in a non-GC 
> app).
> 
> The first thing I'd look for is using CFRelease() when you should call 
> -release (or vise versa, and the same for retain): code written pre-GC would 
> treat those as equivalent, but in a GC or optional-GC world they need to be 
> treated as operating on distinct kinds of refcount.
> 
> 

___

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

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

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

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


Re: Quick Looking big files crash

2011-05-03 Thread Nick Zitzmann

On May 3, 2011, at 5:27 PM, Brad Stone wrote:

> My app stores an NSURL to a file.  All I'm doing is acting as the data source 
> and delegate for QL and giving it access to an NSArray with the URL.  I'm not 
> creating a plugin (or am I misunderstanding you). 

No, when you said "QuickLook" I thought "QuickLook plugin", sorry. Does setting 
a symbolic breakpoint on auto_zone_resurrection_error get any bites?

Nick Zitzmann


___

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

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

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

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


Re: Quick Looking big files crash

2011-05-03 Thread Wim Lewis

On 3 May 2011, at 4:03 PM, Brad Stone wrote:
> I have a symbolic breakpoint set and it stops on 
> auto_refcount_underflow_error, even the small files.  If I continue the doc 
> shows in QL.

Presumably, a few stack frames up, there will be a call to CFRelease() which is 
causing the underflow (what would be an over-released zombie in a non-GC app).

The first thing I'd look for is using CFRelease() when you should call -release 
(or vise versa, and the same for retain): code written pre-GC would treat those 
as equivalent, but in a GC or optional-GC world they need to be treated as 
operating on distinct kinds of refcount.


___

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

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

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

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


Re: Quick Looking big files crash

2011-05-03 Thread Brad Stone
My app stores an NSURL to a file.  All I'm doing is acting as the data source 
and delegate for QL and giving it access to an NSArray with the URL.  I'm not 
creating a plugin (or am I misunderstanding you). 

On May 3, 2011, at 6:59 PM, Nick Zitzmann wrote:

> 
> On May 3, 2011, at 4:45 PM, Brad Stone wrote:
> 
>> Here's what I get when I QL a large file.
>> 
>> proNotes(52698,0x1196fd000) malloc: reference count underflow for 
>> 0x201afc920, break on auto_refcount_underflow_error to debug. (17 times)
>> proNotes(52698,0x1196fd000) malloc: resurrection error for object 
>> 0x201f0a380 while assigning {conservative-block}[352](0x20189fc40)[304] = 
>> CFRunLoopSource[128](0x201f0a380)
>> garbage pointer stored into reachable memory, break on 
>> auto_zone_resurrection_error to debug (13 times)
>> 
>> 
>> Then crash.  What should I look for?  How should I approach debugging this?
> 
> 
> Do this:
> 
> 1. In your project, add an executable for /usr/bin/qlmanage
> 2. Give it an argument that points to a file that your importer handles, plus 
> any flags you need to pass to the task
> 3. If you haven't done so already, make a symbolic link pointing to your 
> built importer product, and place it where you normally place your QuickLook 
> generators (so it loads the built product instead of a copy of the built 
> product)
> 4. Make a symbolic breakpoint for auto_zone_resurrection_error
> 5. Build and debug
> 
> If you set up everything correctly, then Xcode's debugger will launch 
> qlmanage, which will load your plugin, and trigger the problem, and cause the 
> debugger to break. Good luck; debugging plugins isn't always easy.
> 
> Nick Zitzmann
> 
> 

___

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

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

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

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


Re: Quick Looking big files crash

2011-05-03 Thread Brad Stone
I have a symbolic breakpoint set and it stops on auto_refcount_underflow_error, 
even the small files.  If I continue the doc shows in QL.

On May 3, 2011, at 6:52 PM, Wim Lewis wrote:

> 
> On 3 May 2011, at 3:45 PM, Brad Stone wrote:
>> Here's what I get when I QL a large file.
>> 
>> proNotes(52698,0x1196fd000) malloc: reference count underflow for 
>> 0x201afc920, break on auto_refcount_underflow_error to debug. (17 times)
>> proNotes(52698,0x1196fd000) malloc: resurrection error for object 
>> 0x201f0a380 while assigning {conservative-block}[352](0x20189fc40)[304] = 
>> CFRunLoopSource[128](0x201f0a380)
>> garbage pointer stored into reachable memory, break on 
>> auto_zone_resurrection_error to debug (13 times)
>> 
>> 
>> Then crash.  What should I look for?  How should I approach debugging this?
> 
> Have you tried breaking on auto_refcount_underflow_error and 
> auto_zone_resurrection_error?
> 
> 
> ___
> 
> 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/cocoa-dev%40softraph.com
> 
> This email sent to cocoa-...@softraph.com

___

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

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

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

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


Re: Quick Looking big files crash

2011-05-03 Thread Nick Zitzmann

On May 3, 2011, at 4:45 PM, Brad Stone wrote:

> Here's what I get when I QL a large file.
> 
> proNotes(52698,0x1196fd000) malloc: reference count underflow for 
> 0x201afc920, break on auto_refcount_underflow_error to debug. (17 times)
> proNotes(52698,0x1196fd000) malloc: resurrection error for object 0x201f0a380 
> while assigning {conservative-block}[352](0x20189fc40)[304] = 
> CFRunLoopSource[128](0x201f0a380)
> garbage pointer stored into reachable memory, break on 
> auto_zone_resurrection_error to debug (13 times)
> 
> 
> Then crash.  What should I look for?  How should I approach debugging this?


Do this:

1. In your project, add an executable for /usr/bin/qlmanage
2. Give it an argument that points to a file that your importer handles, plus 
any flags you need to pass to the task
3. If you haven't done so already, make a symbolic link pointing to your built 
importer product, and place it where you normally place your QuickLook 
generators (so it loads the built product instead of a copy of the built 
product)
4. Make a symbolic breakpoint for auto_zone_resurrection_error
5. Build and debug

If you set up everything correctly, then Xcode's debugger will launch qlmanage, 
which will load your plugin, and trigger the problem, and cause the debugger to 
break. Good luck; debugging plugins isn't always easy.

Nick Zitzmann


___

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

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

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

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


Re: Quick Looking big files crash

2011-05-03 Thread Wim Lewis

On 3 May 2011, at 3:45 PM, Brad Stone wrote:
> Here's what I get when I QL a large file.
> 
> proNotes(52698,0x1196fd000) malloc: reference count underflow for 
> 0x201afc920, break on auto_refcount_underflow_error to debug. (17 times)
> proNotes(52698,0x1196fd000) malloc: resurrection error for object 0x201f0a380 
> while assigning {conservative-block}[352](0x20189fc40)[304] = 
> CFRunLoopSource[128](0x201f0a380)
> garbage pointer stored into reachable memory, break on 
> auto_zone_resurrection_error to debug (13 times)
> 
> 
> Then crash.  What should I look for?  How should I approach debugging this?

Have you tried breaking on auto_refcount_underflow_error and 
auto_zone_resurrection_error?


___

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


Quick Looking big files crash

2011-05-03 Thread Brad Stone
I added Quartz and QuickLook frameworks to my garbage-collection-required app 
and then added simple Quick Look functionally.  

The bigger the file the more errors I get.  Small pdfs show no errors, large 
ppts, xl or zip files show a bunch of errors and eventually crash.  I'm not 
familiar with non-garbage collection memory management.  I wouldn't even be 
able to determine if these errors are telling me I should be.  Please help.

Here's what I get when I QL a large file.

proNotes(52698,0x1196fd000) malloc: reference count underflow for 0x201afc920, 
break on auto_refcount_underflow_error to debug. (17 times)
proNotes(52698,0x1196fd000) malloc: resurrection error for object 0x201f0a380 
while assigning {conservative-block}[352](0x20189fc40)[304] = 
CFRunLoopSource[128](0x201f0a380)
garbage pointer stored into reachable memory, break on 
auto_zone_resurrection_error to debug (13 times)
 

Then crash.  What should I look for?  How should I approach debugging this?

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


Re: objects and "global / shared data"

2011-05-03 Thread Allyn Bauer
(replying to all this time)..

A singleton may be an appropriate solution to this problem. Their usage is not 
perfect but few tools are.

That said, "DataHandler" should probably not be the singleton. That is the 
class you created to read the file. If it doesn't make sense to create another 
object to model your data (and it sounds like it may not - if it is an array. 
It depends on what it is an array of), then you can store this array in your 
application delegate and use [[UIApplication sharedApplication] delegate] to 
get access to it that way.

The other thing to keep in mind is you might indeed not need a singleton. For 
example, if you have a simple navigation hierarchy as such:

List of objects -> object details

Then you can get the data from your DataHandler and load it into the list of 
objects controller. When the user selects the thing, you simply pass the object 
around and it is updated. Storing the array of items in this scenario in a 
singleton/as a singleton is incorrect, and eventually you will wish you hadn't.

Basically,
> 
> But the menu is created in a different class than the one managing the 
> tableview.
Probably means, only create the menu once, and pass the pointer around. :)


Hope that helps,

Allyn

On May 3, 2011, at 5:08 PM, Martin Batholdy wrote:

> Hi,
> 
> I am still new to objective-c and cocoa and the whole object-oriented 
> approach.
> 
> So perhaps this is a weird question for you, but for me it is really 
> important to understand.
> 
> I have a small program with a DataHandler-class.
> This class has methods to get data from a file on the disk and to save it.
> 
> Actually it reads a plist containing an Array.
> 
> Now I need this Array at different places in my program.
> I want to display it in a menu and in a tableView.
> 
> But the menu is created in a different class than the one managing the 
> tableview.
> 
> However both classes need the data from the DataHandler.
> 
> So they separately initiate their own instance of DataHandler.
> Now the problem is that when one class changes something in the array the 
> other class doesn't know about that,
> because it has its own instance of the DataHandler.
> 
> Now how can I make sure that a global data-source is available independent 
> from instances and their state?
> How can I share data between objects?
> 
> I read something about singletons and that  by declaring the DataHandler 
> object a singleton I can make sure that over the whole program only one 
> DataHandler-instance is initiated,
> and the actual Data-Array is the same in each instance.
> 
> But I also read that singletons are bad practice.
> 
> But how can I share data (an Array) over different objects?
> 
> 
> I still don't get this point ...
> 
> Or do I have to use CoreData?
> 
> 
> 
> 
> ___
> 
> 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/allyn.bauer%40gmail.com
> 
> This email sent to allyn.ba...@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: objects and "global / shared data"

2011-05-03 Thread Nick Zitzmann

On May 3, 2011, at 4:08 PM, Martin Batholdy wrote:

> Now how can I make sure that a global data-source is available independent 
> from instances and their state?
> How can I share data between objects?

I would recommend making a singleton "manager" object that holds instances of 
this data handler object, and can be used to query these objects. We do this 
with data stores in several of our projects, and it works quite well. You may 
only have one data store object at this time, but if you ever need to add more 
than one, it's cheaper to adopt this design now than it is to uproot things 
later.

> I read something about singletons and that  by declaring the DataHandler 
> object a singleton I can make sure that over the whole program only one 
> DataHandler-instance is initiated,
> and the actual Data-Array is the same in each instance.
> 
> But I also read that singletons are bad practice.

That is not true. Where did you read that?

Nick Zitzmann


___

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


objects and "global / shared data"

2011-05-03 Thread Martin Batholdy
Hi,

I am still new to objective-c and cocoa and the whole object-oriented approach.

So perhaps this is a weird question for you, but for me it is really important 
to understand.

I have a small program with a DataHandler-class.
This class has methods to get data from a file on the disk and to save it.

Actually it reads a plist containing an Array.

Now I need this Array at different places in my program.
I want to display it in a menu and in a tableView.

But the menu is created in a different class than the one managing the 
tableview.

However both classes need the data from the DataHandler.

So they separately initiate their own instance of DataHandler.
Now the problem is that when one class changes something in the array the other 
class doesn't know about that,
because it has its own instance of the DataHandler.

Now how can I make sure that a global data-source is available independent from 
instances and their state?
How can I share data between objects?

I read something about singletons and that  by declaring the DataHandler object 
a singleton I can make sure that over the whole program only one 
DataHandler-instance is initiated,
and the actual Data-Array is the same in each instance.

But I also read that singletons are bad practice.

But how can I share data (an Array) over different objects?


I still don't get this point ...

Or do I have to use CoreData?




___

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: Binding multiple NSTableView and NSPopupButton to an NSArrayControler

2011-05-03 Thread Lorenzo Thurman
On Mon, May 2, 2011 at 3:15 PM, Quincey Morris
wrote:

> On May 2, 2011, at 12:47, lorenzo7...@gmail.com wrote:
>
> > anotherItemController
> > Content Array
> > Bind to: MyAppsClass (added an NSObject from palette and set its class to
> MyAppsClass)
> > Controller Key: myMutableArray
>
> If this is what you were calling a "proxy" earlier, it isn't. It's a
> separate instance of MyAppsClass that's (re-)created when the nib is loaded.
>
> I'm assuming that MyAppsClass represents an app delegate singleton. The
> normal way to create it is to place an instance in the MainMenu nib, and
> connect the Application proxy's delegate outlet to it.
>
> If the nib file you're referring to above is actually the MainMenu nib,
> then that's fine. If not, then you've created a second instance -- you
> shouldn't have added a NSObject from the palette, but should have bound to
> the Application proxy instead, using the "delegate" key to get to the
> existing singleton object.
>
> > If I set a breakpoint after the item has been removed and then in gdb: po
> (NSArray*)[mycontroller arrangedObjects] . The removed item is not in the
> array. If during archiving, I do the same, the removed item is back.
>
> You kind of sidestepped the question here. There are, if I understand
> correctly, 2 different array controllers (one for each NIB), both of which
> are supposed to use the same underlying data model array for their content.
> You're not saving the array controllers (at least I hope not), but you're
> saving the underlying data model. Therefore looking at the array controller
> (or even their arrangedObjects) doesn't tell you anything about what's being
> saved.
>
> What you should be trying to resolve, using the debugger, is the question
> of whether there are 2 underlying data model arrays when there should be
> only one. To do that, you need to be looking at the object address of the
> mutable array(s).
>
>
>
So, I finally figured it out, and yes there were two array instances. I
removed what I referred to as the "Proxy object" representing the class that
actually has the mutable array (MyAppsClass) and just changed the File's
Owner to MyAppsClass.  My window controller subclass was initially the
File's Owner for that NIB. The bindings for the NSPopupButton are the same
as before. For the Window holding the NSTableView, these are the bindings:

myArrayController Content Array
Bind To:
Files's Owner
Model Key Path
mutable array

NSTableViewColumn Value
Bind To:
myArrayController
Model Key Path
arrangedObjects

I see the error of my ways now. These latest changes were what I initially
setup when building the interface. When I ran the app, I got an error saying
my window controller subclass was not key value compliant for my mutable
array. That sent me down the rat hole of adding an NSObject and changing its
class to MyAppsClass, to give me a path to the mutable array. This felt a
bit hinky anyway.

What I had overlooked was how I was initializing the window controller
subclass. I was using -(id)initWithWindowNibName, which, of course, sets the
owner to the window controller subclass, thus the key value error. What I
needed to do all along was simply use -(id) initWithWindowNibName: owner:.
Setting owner to MyAppsClass. Now File's Owner->mutable array gives me the
correct Key Path and items removed from the table are removed from the popup
button and everything is written out to disk correctly.

One should always RTFM, even if one thinks he/she understands the FM.

Oh well, lesson learned.
Thanks for making me look a bit harder.



-- 
"My break-dancing days are over, but there's always the funky chicken"
--The Full Monty
___

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: UIView not loading

2011-05-03 Thread Matt Neuburg
On Tue, 03 May 2011 20:34:42 +1000, Brian Bruinewoud  said:
>What I'm trying to do:
>In a popover, I have buttons
>On touching a button, a subview will be created in the main view of the screen 
>(that is, beneath the popover)

>UIViewController *newRoom = [[ Room alloc ] initWithNibName: @"Room" 
> bundle: nil ];
>if( !newRoom )
>NSLog(@"Extra Huh?!");
>
>NSBundle *b = newRoom.nibBundle;
>NSString *n = newRoom.nibName;
>BOOL  l = newRoom.isViewLoaded;
>
>NSLog(@"bundle:%@  nib:%@  loaded:%d", b, n, l );
>
>UIView *nrV = newRoom.view;
>if( !nrV )
>NSLog(@"Huh?");

Don't use a view controller in this way. View controllers are for views that 
occupy the entire screen (e.g. the root view of the window) or for situations 
where something contains a view controller (such as an UINavigationController 
or a UIPopoverController). They are not for dumpster-diving in nibs. Just have 
a plain object subclass of your own with an outlet and use it as the nib's 
owner as you load the nib.

Also, what you're doing with loadView is insane. If you implement loadView, 
that means the view will not be loaded from the nib, so you're cancelling out 
the very thing you want to do. If you implement loadView you *must* supply the 
view right there and set the view property manually.

http://www.apeth.com/iOSBook/ch19.html

m.

--
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook___

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


Vertical alignment in NSTextView

2011-05-03 Thread Rimas M.
Hello,

I continue my fight with cocoa text system :)) At the moment I am loosing..

Now I am trying to implement vertical text alignment in NSTextView. If
I would need only drawing, would be quite easy. But I need to maintain
an editing capability.

The thing I am talking about is very similar (or even the same) to the
text writing inside shape (rectangle) using Keynote: insert rectangle
shape, double click it ant write some text. Using inspector (Text tab)
you can choose between top, middle and bottom vertical alignment.

I am almost sure, that I need to subclass and overwrite some stuff
from either NSLayoutManager or NSATSTypesetter. Just not sure which
exact... Any thoughts?

Best Regards,

Rimas M.
___

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: block animation

2011-05-03 Thread David Duncan
On May 3, 2011, at 3:40 AM, Brian Bruinewoud wrote:

> Hi All,
> 
> self.view.alpha is animated but nothing at all happens to drawingVC.view.


My guess would be that 'drawingVC.view' isn't actually in a window anywhere.

Given your current and previous question however, I would posit that you are 
mis-using UIViewControllers and possibly causing various other issues for 
yourself (that said, I don't know why you get the results you do in your other 
question).

I would highly recommend that you read the View Controller Programming Guide, 
especially the section on view controller containment (spoiler alert: what you 
are doing is not supported). If you want to be able to load arbitrary views 
from nibs to add to a view managed by a view controller, the recommendation is 
to use an NSObject subclass to own the view and UINib to load the nib.
--
David Duncan

___

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

2011-05-03 Thread Rimas M.
Hello Aki,

Thank you for reply.
Looks like I will need to learn lots of new things, because fonts
metrics are unknown world for me.

I have played a bit with "rect of glyph" from NSFont and
NSLayoutManager. Some useful information can be found. But lots of
unclear things are mostly with baselines and offsets of them.. For
example NSFont's boundingRectForGlyph: returns rect, which looks like
gonna fit whole glyph, but currently I have no idea how to calculate
its position (x and y) in the line of TextView/LayoutManager.

Regards,

Rimas M.

On Wed, Apr 27, 2011 at 11:06 PM, Aki Inoue  wrote:
> Rimas,
>
> Typically the text layout system including the Cocoa Text System works in the 
> typographic metrics that's based on the information embedded in the font.  
> So, most layout information returned by NSLayoutManager is in the typographic 
> metrics if not documented otherwise.
>
> The information you're seeking here is usually called the rendering or image 
> metrics.  They are based on the actual rendering results in the graphics 
> system.
>
> The typographic metrics and image metrics are usually not compatible.  Also, 
> the image metrics usually requires the rendering result (various graphical 
> settings could change the pixels touched).
>
>
>> 2. With some fonts (for example Eccentric Std, Palemonas, some others
>> which i can't remember right now) the [myLayoutManager
>> usedRectForTextContainer:myTextContainer] returns rect which does not
>> covers WHOLE text.
>
> You can calculate the image bounds by union'ing the bounds of each glyph in 
> the layout manager.  See -[NSFont getBoundingRects:forGlyphs:count:].
>
>> To draw it correctly, I need a bounding (used) rect,
>> which counts in a shadow attribute. Is it possible at all using cocoa
>> text system?
> This really requires the rendering result.  You can "estimate" the bounds by 
> applying the shadow params to the bounding rect from above.
>
> Aki
>
> On 2011/04/27, at 8:34, Rimas M. wrote:
>
>> Hi folks,
>>
>> Last few days I am trying to solve very strange puzzle - how to draw
>> FULL attributed string.
>>
>> Short story:
>>
>> I have a NSTextStorage object, which holds my formatted string
>> information. I am editing it via NSTextView (NSLayoutManager +
>> NSTextContainer + my NSTextStorage) mechanism. That works great until
>> I am dealing with drawing. To find out rect, which will be required to
>> fit my text, I am using -
>> (NSRect)usedRectForTextContainer:(NSTextContainer *)aTextContainer of
>> NSLayoutManager. To draw actual content I am using
>> drawBackgroundForGlyphRange:(NSRange)glyphsToShow
>> atPoint:(NSPoint)origin and
>> drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin
>> from the same NSLayoutManager. And that works great for 90% of time.
>> But I need 100%.
>>
>> Problem:
>>
>> Actually I am dealing with two drawing problems:
>>
>> 1. When my attributed string (NSTextStorage) has a shadow, made by
>> using Fonts panel, it is NOT INCLUDED when trying to find out used
>> rect by calling [myLayoutManager
>> usedRectForTextContainer:myTextContainer]. Never. The situation can be
>> easily demonstrated with TextEdit:
>> https://www.dropbox.com/s/vt21zpq46xl0gb5/Text-with-cropped-shadow.png
>> . The same I am getting in my app. But I need a shadow, therefor I
>> have set it. To draw it correctly, I need a bounding (used) rect,
>> which counts in a shadow attribute. Is it possible at all using cocoa
>> text system?
>>
>> 2. With some fonts (for example Eccentric Std, Palemonas, some others
>> which i can't remember right now) the [myLayoutManager
>> usedRectForTextContainer:myTextContainer] returns rect which does not
>> covers WHOLE text. Sometimes diacritic symbols of the very top line
>> are missing 
>> (https://www.dropbox.com/s/dpjjugzxcnp771r/Missing-diacrytic-symbol.png
>> <- both letters are the same "Alt + e + e = é" combination), sometimes
>> the first left symbol is cropped
>> (https://www.dropbox.com/s/33mfgoqwbgwcvg1/Cropped-left-side-1.png,
>> https://www.dropbox.com/s/kbgfdzuhcr1svht/Cropped-left-side-2.png,
>> https://www.dropbox.com/s/ntxgufl8e562uep/Cropped-left-side-3.png).
>> Question is the same - how to get rect, which would fit my whole text.
>>
>> Any help is very appreciate.
>>
>> p.s. don't hesitate to ask for an additional information. I could even
>> make a small sample app if required.
>>
>> Regards,
>>
>> Rimas M.
>> ___
>>
>> 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/aki%40apple.com
>>
>> This email sent to a...@apple.com
>
>
___

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

Please do not post admin requests or moderator comments to the list.
C

Re: Customizing UIActionSheet button accessibility labels.

2011-05-03 Thread Eloy Duran
FYI, I have worked around this with the following subclass which
allows me to customize the labels: https://gist.github.com/953326

I have filed the following radar ticket for this issue:
http://openradar.appspot.com/radar?id=1174411

On Fri, Apr 29, 2011 at 8:21 PM, Eloy Duran  wrote:
> I have been unable to figure out if and how to customize the labels of the 
> buttons in a UIActionSheet. I would have expected it would implement the 
> UIAccessibilityContainer protocol, but it doesn't return useful data for any 
> of the protocol's methods… What am I missing?
>
> Eloy
___

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


Drag and drop issue - latest track pad and 10.6

2011-05-03 Thread Peter Hudson

Hi All

Have a piece of drag and drop code that has worked perfectly for a  
long time on Intel laptops with the trackpad and mouse button.


One of our users with the latest type of Macbook Pro ( integrated  
trackpad and mouse ) can produce problems in this drag and drop code.


The result of their drag and drop  look as though the  
acceptDrop:   method has only partially executed.


The problem is sporadic and I have never been able to replicate it.

Suggestions  ?


Peter
___

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

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

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

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


Re: UIGestureRecognizer in superview firing

2011-05-03 Thread Roland King

On 03-May-2011, at 12:30 AM, Matt Neuburg wrote:

> On Mon, 02 May 2011 16:15:59 +0800, Roland King  said:
>> I have a UIView subclass which has a number of UIButtons and UISliders on 
>> it, it's a sort of control panel. I added UIPanGestureRecognizer to it with 
>> the idea that if you stick your finger down outside one of the embedded 
>> controls, you can move the window around. Wrote the handler for the gesture 
>> recognizer, that worked. 
>> 
>> However I found that if I press one of the buttons, or try to drag one of 
>> the sliders which are subviews of my view, the PanGestureRecognizer fires. 
>> That completely breaks those controls as the sliders stop sliding and you 
>> cannot drag yourself off the button to cancel the press, you just drag the 
>> view around. 
>> 
>> I've re-read the UIGestureRecognizer documentation again twice and cannot 
>> figure out why this is happening.
> 
> This is correct behavior and is very thoroughly explained in my book (Chapter 
> 18, "Touches"). As I say there, you need to think of a view as surrounded by 
> a swarm of gesture recognizers - those attached to the view, those attached 
> to its superview, and so on up the chain. Every gesture recognizer in the 
> swarm gets a crack at recognizing any gesture; if any does, then (by default) 
> all the other gesture recognizers in the swarm are made to fail.
> 
> The reason for this behavior is obvious if you consider the case of two views 
> where you put one finger on each view and rotate around their common center. 
> Neither view can detect this gesture, since it is a two-finger gesture and 
> each view knows about only one finger, so the only way this can work is to 
> attach the rotate gesture recognizer to the superview. This in turn implies 
> that touches must be delivered to gesture recognizers up the superview chain.
> 
>> I'm going to use the PanGestureRecognizer delegate method 
>> gestureRecognizer:shouldReceiveTouch: to stop this happening.
> 
> That's correct. It's very easy to implement this, because a touch has a view, 
> so you can detect immediately that this touch was not on the superview. m.
> 

That's two questions of mine you've answered in two days Matt, thanks very 
much. 

It makes some sense that gesture recognizers work like that, as you say if the 
touches weren't passed to the superview recognizers there's no way you could 
recognize 'macro' gestures, whereas it's quite easy with that one delegate 
method to turn the behavior off if you don't want it. 

That is however exactly NOT what the documentation says, it gives no hint at 
all that gesture recognizers above the hit-tested view will be tickled nor does 
it really go into what circumstances you might want to use 
gestureRecognizer:shouldReceiveTouch:. I agree the actual behavior makes sense 
so I'll file a documentation bug on that, googling around I'm not the only 
person confused by this. ___

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

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

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

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


how to add/remove button to a cell in tableview

2011-05-03 Thread Abhijeet Singh
Hi,There are four columns in my table view. The last column is empty. At run 
time I want to add a button to the last column depending upon a condition. If a 
condition is true for a row, button should be added (appeared) to the last 
column of the row. If condition is not true any more for a row the button 
should be removed from the last column of the row. I have used  (NSCell 
*tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn 
*)tableColumn row:(NSInteger)rowIt adds the button but i am not able to remove 
it from the cell. Thanks & RegardsAbhijeetDear macosxdev ! Get Yourself a cool, 
short @in.com Email ID now! Dear macosxdev ! Get Yourself a cool, short @in.com 
Email ID now! Dear cocoadev ! Get Yourself a cool, short @in.com Email ID now!
___

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


block animation

2011-05-03 Thread Brian Bruinewoud
Hi All,

This animation doesn't code doesn't work properly:

  - (IBAction) gotClicked: (id) sender
  {
[UIView animateWithDuration: 1.0
  delay: 0.0
options: UIViewAnimationOptionCurveEaseIn
 animations:^{
 self.view.alpha = 0.0;
 drawingVC.view.alpha = 0.0;
 drawingVC.view.frame = CGRectMake(400, 400, 400, 400);
 }
 completion::nil];
  }

self.view.alpha is animated but nothing at all happens to drawingVC.view.

The documentation says that multiple views can be animated in the block and it 
doesn't say that there are any limitations as to where those views are so I'm 
not sure why it doesn't work. Both views are UIViews.

Having said that, I really have no mental model as to how these block based 
animations are implemented behind the scenes so I have no means of reasoning 
about these items. Can someone explain how animateWithDuration: is implemented 
in regards to the block? It doesn't have to be the actual implementation, just 
a reasonable one.

Thanks,
Brian.___

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


UIView not loading

2011-05-03 Thread Brian Bruinewoud
Hi All,

This has got me annoyingly stumped. 

What I'm trying to do:
In a popover, I have buttons
On touching a button, a subview will be created in the main view of the screen 
(that is, beneath the popover)

What's not happening:
The view isn't being instantiated
For debugging purposes, I've implemented the loadView method on the appropriate 
view controller to call super and log a message but the message never appears 
implying that loadVIew isn't being called.

Code where I try to create the view. This is the action behind the touch event.
  - (IBAction) addRoom: (id) sender;
  {
UIViewController *newRoom = [[ Room alloc ] initWithNibName: @"Room" 
bundle: nil ];
if( !newRoom )
NSLog(@"Extra Huh?!");

NSBundle *b = newRoom.nibBundle;
NSString *n = newRoom.nibName;
BOOL  l = newRoom.isViewLoaded;

NSLog(@"bundle:%@  nib:%@  loaded:%d", b, n, l );

UIView *nrV = newRoom.view;
if( !nrV )
NSLog(@"Huh?");

newRoom.view.frame = CGRectMake( 0, 0, 100, 100 );
newRoom.view.alpha = 0;

[ self.view addSubview: newRoom.view ];

nrV = newRoom.view;
if( !nrV )
NSLog(@"Still Huh?");
  }


Code in loadView.
  - (void) loadView
  {
[ super loadView ];
NSLog( @"Room::loadView" );
  }

The logging produced is this:
  2011-05-03 20:10:45.210 drawing[924:207] Room::initWithNibName: Room bundle: 
(null)
  2011-05-03 20:10:45.212 drawing[924:207] bundle:NSBundle 
 (loaded)  nib:Room  loaded:0
  2011-05-03 20:10:45.213 drawing[924:207] Huh?
  2011-05-03 20:10:45.216 drawing[924:207] Still Huh?

Why isn't the view being created? What do I need to do to force it to be 
created?

Thanks,
Brian.___

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


Position of baseline in text view

2011-05-03 Thread Дмитрий Николаев
Hello!

If there any possibility to calculate position of baseline for specified glyph 
? I need to draw line of dots at the level of baseline of last glyph, as in 
"table of contents".


Chapter 1. 540
Chapter 123. 670


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