NSString accessing characters

2011-06-17 Thread Andreas Grosam
Hi All,


I've written a parser which can natively parse any Unicode encoding form 
(UTF-8, UTF16 BE/LE, UTF-32 BE/LE). It takes iterators as input parameters, 
that is (const) pointers to uint8_t, uint16t and uint32_t which are selected 
according the Unicode encoding form of the given input text.

So, the interface looks basically as followed (global free function):

id parse(Iterator first, Iterator last);

where 'Iterator' is one of the mentioned iterator types above, and 'first' is 
the beginning of the text, and 'last' is an iterator representing the end of 
the text. 


Given an NSString as input source, what is the fastest method to "feed" the 
parser?

Also worth mentioning is the possible fact about hidden autoreleased memory 
objects, for instance when retrieving c-strings from the NSString object or 
when converting the NSString's internal encoding to some specified external 
form.


Thanks for tips,

Andreas



___

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

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

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

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


Re: NSString accessing characters

2011-06-17 Thread Ken Thomases
On Jun 17, 2011, at 2:46 AM, Andreas Grosam wrote:

> I've written a parser which can natively parse any Unicode encoding form 
> (UTF-8, UTF16 BE/LE, UTF-32 BE/LE). It takes iterators as input parameters, 
> that is (const) pointers to uint8_t, uint16t and uint32_t which are selected 
> according the Unicode encoding form of the given input text.
> 
> So, the interface looks basically as followed (global free function):
> 
> id parse(Iterator first, Iterator last);
> 
> where 'Iterator' is one of the mentioned iterator types above, and 'first' is 
> the beginning of the text, and 'last' is an iterator representing the end of 
> the text. 
> 
> 
> Given an NSString as input source, what is the fastest method to "feed" the 
> parser?
> 
> Also worth mentioning is the possible fact about hidden autoreleased memory 
> objects, for instance when retrieving c-strings from the NSString object or 
> when converting the NSString's internal encoding to some specified external 
> form.

First, you're probably prematurely optimizing.  The chance that accessing the 
string contents will be a significant portion of the time taken by parsing is 
small.

That said, I guess you should try CFStringGetCharactersPtr() and 
CFStringGetCStringPtr() first.  If either returns non-NULL, then that's about 
as fast as you're going to get.  After that, maybe use 
CFStringInitInlineBuffer() and CFStringGetCharacterFromInlineBuffer(), although 
that doesn't fit with your iterator interface.  You could wrap an iterator 
around them easily, though.  After that, it probably doesn't matter much.  
You'll be doing some combination of allocation and encoding conversion no 
matter what.  So, go with the most convenient method, which will probably be 
back in Objective-C.

Regards,
Ken

___

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

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

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

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


Re: NSString accessing characters

2011-06-17 Thread Quincey Morris
On Jun 17, 2011, at 00:46, Andreas Grosam wrote:

> Given an NSString as input source, what is the fastest method to "feed" the 
> parser?

As usual, Ken's answer is better than the one I was composing, but I don't 
think *any* answer is of use to you unless you specify what representation your 
parser is converting *to*.

If it's something that NSString can encode to, then you're probably better off 
not using your parser.

If not, it might be fastest to first convert the string to whatever encoding 
your parser is itself fastest at parsing.

Or, if your parser is very fast for all the encodings it accepts, try using 
'[NSString fastestEncoding]' to see if it's one that your parser can handle. 
I'd bet that for very large strings (the only ones you'd care about from a 
performance perspective, probably) 'fastestEncoding' is almost always UTF-8 or 
UTF-16, because such strings are statistically likely to have originated in a 
file in one of those two representations.


___

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

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

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

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


Re: NSString accessing characters

2011-06-17 Thread Andreas Grosam

Thank you Ken, for your valuable tips,

On Jun 17, 2011, at 10:40 AM, Ken Thomases wrote:

> On Jun 17, 2011, at 2:46 AM, Andreas Grosam wrote:
> 
>> Given an NSString as input source, what is the fastest method to "feed" the 
>> parser?
>> 
>> Also worth mentioning is the possible fact about hidden autoreleased memory 
>> objects, for instance when retrieving c-strings from the NSString object or 
>> when converting the NSString's internal encoding to some specified external 
>> form.
> 
> First, you're probably prematurely optimizing.  The chance that accessing the 
> string contents will be a significant portion of the time taken by parsing is 
> small.

If possible, I would prefer to avoid any conversions performed by NSString as a 
result of accessing the content in any way. The parser is capable to parse any 
Unicode encoding form, so if possible, I just would take the NSString's content 
"as is" - if it is encoded in a Unicode form, and - of course - if I am able to 
figure out what actual encoding this is.

Given the parser's speed, any encoding conversion made by NSString is a 
significant performance penalty.

A priory I cannot determine what UTF encoding form the original source is 
encoded to, but in almost all cases it is UTF-8.


> 
> That said, I guess you should try CFStringGetCharactersPtr() and 
> CFStringGetCStringPtr() first.  If either returns non-NULL, then that's about 
> as fast as you're going to get.  
Aha! I read the docs and that's probably what I need. 

If I understood the functions correctly, CFStringGetCharactersPtr() returns 
non-NULL if the internal representation is UTF-16 (machine endianness, I 
guess). If CFStringGetCStringPtr(theString, kCFStringEncodingUTF8) returns 
non-NULL the internal representation equals UTF-8.

Now, there is the possibility that the original source, where the NString has 
been initialized, is provided as UTF-32, but this is rather unlikely. In that 
case, I guess, NSString will perform a conversion internally to either UTF-16 
or else. Possibly in this case, I need to convert to some UTF encoding form 
before feeding the parser.


> After that, maybe use CFStringInitInlineBuffer() and 
> CFStringGetCharacterFromInlineBuffer(), although that doesn't fit with your 
> iterator interface.  You could wrap an iterator around them easily, though.
Yes, I can wrap any kind of iterators around the pointers. The parser just 
requires the semantics of an Input Iterator. In fact, internally the parser 
applies an iterator adapter anyway to support byte-swapping, if needed.

(The iterator interface exists due to support streams. But I haven't thought 
about using NSStreams so far - hopefully this will work as well).

I don't understand the purpose of the "inline buffer" facility fully, though. 
Is accessing a NSString's content through an inline buffer faster than 
accessing the content of a raw pointer whose content has a known encoding?

>  After that, it probably doesn't matter much.  You'll be doing some 
> combination of allocation and encoding conversion no matter what.  So, go 
> with the most convenient method, which will probably be back in Objective-C.
> 

OK, thank you very much for the tips!

Andreas


> Regards,
> Ken
> 

___

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

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

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

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


Re: pagingEnabled on NSScrollView?

2011-06-17 Thread Leonardo
Hi, thanks,
it works. But now I get a new trouble:
If I set setHasHorizontalScroller:NO, any scrollPoint: I call
programmatically is not seen by the next drag.
In details:

within the method endGestureWithEvent: I call
NSLog(@"endGesture %@", NSStringFromPoint([mClipView bounds].origin));
// and I get X = 50;

[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(scrollToPageNum:) object:nil];
// now we go and adjust the scroll to 100.
[self performSelector:@selector(scrollToPageNum:) withObject:NumI(page)
afterDelay:0];


within the scrollToPageNum: I programmatically scroll the clipView to the
X point = 100.
[mDocView scrollPoint:newPoint];
[self reflectScrolledClipView:mClipView];
[self display];

Now I can see the page well positioned at X = 100
Also, if I check with
NSLog(@"scrollToPage %@", NSStringFromPoint([mClipView bounds].origin));
everything looks ok. I get X = 100;

Now If a drag again on the trackpad, the clipView moves suddenly to the X=50
then I can drag the page. Wrong! When setHasHorizontalScroller:YES the error
doesn't occur.

What do I miss?


Regards
-- Leonardo


> Da: Quincey Morris 
> Data: Thu, 16 Jun 2011 16:17:53 -0700
> A: Leonardo 
> Cc: 
> Oggetto: Re: pagingEnabled on NSScrollView?
> 
> On Jun 16, 2011, at 14:57, Leonardo wrote:
> 
>> I would like to reach the same effect as UIScrollView.pagingEnabled, but on
>> an NSScrollView. Can that be done?
>> 
>> If not, which technique should I use?
>> I thought to deal with NSAnimationContext to move the scrollView's document
>> with scrollPoint: when a scrolling ends (the finger stops dragging on the
>> track-pad). Am I on the right way?
> 
> NSScrollView is not designed to have this behavior, so you'll have to do the
> work.
> 
> The basic approach is to have (say) your window controller monitor the scroll
> view's clip view's frame- and bounds-changed notifications. When you receive
> these notifications, you examine the relationship between the "clip" view
> bounds and the "document" (i.e. enclosed) view frame, and adjust the
> relationship to align the two views however you want.
> 
> To detect when scrolling "ends", you can use a well-known trick. When you see
> a notification, don't perform the scrolling adjustment immediately, but
> schedule it for "later" using 'performSelector: ... afterDelay: 0'. Since you
> don't want multiple deferred adjustments to get queued, you first cancel any
> pending ones with one of the 'cancelPrevious...' or 'cancelPerform...'
> methods, just before invoking 'performSelector:...'. That way, the last one
> "wins".
> 
> If you want to have this adjustment animate, you should be able to use the
> appropriate view's animator or NSViewAnimation to move the document view
> frame.
> 
> The only difficulty I can think of is if Lion's trackpad gesture-based
> scrolling itself has some animation built into it (e.g. an iOS-like "bounce").
> In that case you might have some trouble trying to integrate your animation
> with the built-in one.
> 
> However, given that all of this is not expected Mac scroll view behavior,
> unless you have a *very* compelling need for it, I'd recommend you don't do
> it. NSScrollView responds to the Page Up and Page Down keys for paging. Why
> limit the user to where you think the page boundaries are?
> 
> 


___

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

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

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

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


Re: NSString accessing characters

2011-06-17 Thread Andreas Grosam

On Jun 17, 2011, at 11:05 AM, Quincey Morris wrote:

> On Jun 17, 2011, at 00:46, Andreas Grosam wrote:
> 
>> Given an NSString as input source, what is the fastest method to "feed" the 
>> parser?
> 
> As usual, Ken's answer is better than the one I was composing, but I don't 
> think *any* answer is of use to you unless you specify what representation 
> your parser is converting *to*.
It does not convert at all. It can understand any Unicode encoding form, though.
Technically, the parser is a C++ template class with the iterator type and the 
encoding form as a template argument. Different treatment is solved through 
specializations, function overloading and argument dependent name-lookup.

> 
> If it's something that NSString can encode to, then you're probably better 
> off not using your parser.
The parser does not encode at all, it just iterates over the text. The purpose 
is parsing a JSON text. The result of the parser is a JSON container, which for 
Objective-C is implemented in standard foundation containers.

> 
> If not, it might be fastest to first convert the string to whatever encoding 
> your parser is itself fastest at parsing.
This will be probably UTF-32 or UTF-16. But it doesn't matter much. Compared to 
the costs of creating the json container, parsing is very fast. Converting a 
NSString's content to a different encoding before feeding the parser would be a 
noticeable cost. Even determining the length of a NSString in a certain 
encoding is already a cost, that must be considered - since it is O(n).
A conversion may also populate the autorelease pool, which is not quite desired.

> 
> Or, if your parser is very fast for all the encodings it accepts, try using 
> '[NSString fastestEncoding]' to see if it's one that your parser can handle.
I've thought about that as well. But the documentation does not say anything 
about whether the NSString's content has to be converted to that said encoding 
before I can actually access it in this "fastest" way. It says, fastestEncoding 
returns the encoding where character retrieval is the fastest and where there 
is no loss of information. It does not say anything about the costs of a 
possibly conversion.
Otherwise, I don't fully understand the method.

> I'd bet that for very large strings (the only ones you'd care about from a 
> performance perspective, probably) 'fastestEncoding' is almost always UTF-8 
> or UTF-16, because such strings are statistically likely to have originated 
> in a file in one of those two representations.

You are right about this. The parser's input almost always originates from a 
network connection. And here, the JSON text is most likely encoded in UTF-8.

However, if I have to deal with "very large input", I guess NSString is no 
option anyway, not only for performance reasons, but also from a memory 
foot-print perspective( IFF my current understanding of NSString is correct, 
namely that its content is stored in memory).
So, for possibly large input, I cannot simply save large amounts of text in 
memory, given we might use the parser on iPhones and similar devices. So, for 
large text, the content is provided as a stream from some network connection. 
The parser then shall also support this form of input, and additionally, it can 
parse while the input is still read, while it is avoided to waste memory for 
buffering the whole text or wasting CPU cycles for saving it to disk. The 
encoding will be determined at runtime at the very start, which is possible. 
Most likely, as you mentioned, it is UTF-8.


Regards
Andreas___

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

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

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

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


Re: Custom NSSlider

2011-06-17 Thread Nick
Thanks guys

 Depends on what you mean by "everyone" ... ?
>
>  QTMovieView and NSMovieView and the likes have built-in controllers that
> you can just use out of the box. Many places use that, however they look
> kinda 10.4-ish. If you want some of the more modern looks (either like
> Spotlight has it, or QuickTime Player X), you'll likely have to roll your
> own.
>
> Cheers,
> -- Uli Kusterer
> "The Witnesses of TeachText are everywhere..."
> http://www.lookandfeelcast.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


NSTextFieldDelegate issues

2011-06-17 Thread JAMES ROGERS
I have an app with six (6) text fields. I need to know when the text in any of 
the text fields has changed so I can process them as a group.

AppDelegate .h
@interface WK2CFGMacAppDelegate : NSObject  {
outlets
}
actions
- (void) textDidChange:(NSNotification *)aNotification;

AppDelegate.m

-(void) awakeFromNib {
[textField setDelegate:self] // for all six fields
}

-(void) textDidChange:(Notification *)aNotification {
NSLog(@"Text changed");
}

The textDidChange method is not being called. Any help would be appreciated.

Jim
JIM ROGERS
jimrogers_w4...@me.com
http://web.me.com/jimrogers_w4atk

___

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: NSTextFieldDelegate issues

2011-06-17 Thread Alexander Reichstadt
Try controlTextDidChange

Am 17.06.2011 um 16:11 schrieb JAMES ROGERS:

> I have an app with six (6) text fields. I need to know when the text in any 
> of the text fields has changed so I can process them as a group.
> 
> AppDelegate .h
> @interface WK2CFGMacAppDelegate : NSObject  NSTextFieldDelegate> {
>   outlets
> }
> actions
> - (void) textDidChange:(NSNotification *)aNotification;
> 
> AppDelegate.m
> 
> -(void) awakeFromNib {
>[textField setDelegate:self] // for all six fields
> }
> 
> -(void) textDidChange:(Notification *)aNotification {
>NSLog(@"Text changed");
> }
> 
> The textDidChange method is not being called. Any help would be appreciated.
> 
> Jim
> JIM ROGERS
> jimrogers_w4...@me.com
> http://web.me.com/jimrogers_w4atk
> 
> ___
> 
> 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/lxr%40mac.com
> 
> This email sent to l...@mac.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: NSTextFieldDelegate issues

2011-06-17 Thread JAMES ROGERS
Wow! That was easy. Thank You!

Jim
On Jun 17, 2011, at 9:21 AM, Alexander Reichstadt wrote:

> Try controlTextDidChange
> 
> Am 17.06.2011 um 16:11 schrieb JAMES ROGERS:
> 
>> I have an app with six (6) text fields. I need to know when the text in any 
>> of the text fields has changed so I can process them as a group.
>> 
>> AppDelegate .h
>> @interface WK2CFGMacAppDelegate : NSObject > NSTextFieldDelegate> {
>>  outlets
>> }
>> actions
>> - (void) textDidChange:(NSNotification *)aNotification;
>> 
>> AppDelegate.m
>> 
>> -(void) awakeFromNib {
>>   [textField setDelegate:self] // for all six fields
>> }
>> 
>> -(void) textDidChange:(Notification *)aNotification {
>>   NSLog(@"Text changed");
>> }
>> 
>> The textDidChange method is not being called. Any help would be appreciated.
>> 
>> Jim
>> JIM ROGERS
>> jimrogers_w4...@me.com
>> http://web.me.com/jimrogers_w4atk
>> 
>> ___
>> 
>> 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/lxr%40mac.com
>> 
>> This email sent to l...@mac.com
> 

JIM ROGERS
jimrogers_w4...@me.com
http://web.me.com/jimrogers_w4atk

___

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

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

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

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


Re: NSString accessing characters

2011-06-17 Thread Jens Alfke

On Jun 17, 2011, at 3:35 AM, Andreas Grosam wrote:

> If possible, I would prefer to avoid any conversions performed by NSString as 
> a result of accessing the content in any way. The parser is capable to parse 
> any Unicode encoding form, so if possible, I just would take the NSString's 
> content "as is" - if it is encoded in a Unicode form, and - of course - if I 
> am able to figure out what actual encoding this is.

An NSString internally uses one of two encodings. One is UTF-16, the other is 
the process’s “default encoding”. The default encoding varies by locale, I 
think, but is generally the highly obsolete MacRoman*. Yes, this means that 
NSString never stores its contents in UTF-8. :(

[Disclaimer: This may have changed since circa 2006, the last time I looked at 
CFString’s internals.]

Given your requirements, I think you’re best off reading the string as UTF-16. 
Probably the fastest ways to go is CFStringGetCharacterFromInlineBuffer, which 
is an optimized iterator that’s inlined in order to get characters out of the 
string in chunks.

> Given the parser's speed, any encoding conversion made by NSString is a 
> significant performance penalty.

I believe you. Back when I studied compilers in college, I was told that 
something like half the parse time is spent in the lexer, simply because it 
operates on every character rather than every token.

> The parser does not encode at all, it just iterates over the text. The 
> purpose is parsing a JSON text. The result of the parser is a JSON container, 
> which for Objective-C is implemented in standard foundation containers.

You may be reinventing the wheel: there are several different JSON parsers for 
Cocoa already. The one I use is SBJson 
. If you already know about these and 
think yours is better, I’d love to know about it (and maybe help out)!

—Jens

* An 8-bit encoding based on ASCII but not at all the same as ISO-8859 (I think 
it predates it.)

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: NSString accessing characters

2011-06-17 Thread Quincey Morris
On Jun 17, 2011, at 04:19, Andreas Grosam wrote:

> It does not convert at all. It can understand any Unicode encoding form, 
> though.

Ah, OK, I misunderstood you to mean "parsing" in relation to the Unicode 
representation itself. That's not as silly as it sounds, because it's not 
entirely trivial to decode UTF-8 or UTF-16 with robust error detection and 
recovery.

> However, if I have to deal with "very large input", I guess NSString is no 
> option anyway, not only for performance reasons, but also from a memory 
> foot-print perspective( IFF my current understanding of NSString is correct, 
> namely that its content is stored in memory).

I think you just answered your own (original) question: you shouldn't be 
considering NSString input at all. Instead, you should be retrieving data from 
all significantly-sized input sources in raw form.

That doesn't mean you shouldn't *accept* NSString input, just that you 
shouldn't waste time on performance optimizations of NSString input. :)


___

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: So... we can't use UIWebView (with a delegate) on a page that's pushed onto a UINavigationController stack?

2011-06-17 Thread David Duncan
On Jun 16, 2011, at 7:15 PM, G S wrote:

> The delegate for the UIWebView is set up in the XIB file; it's pretty
> hokey to have to intervene in code to then disassociate the view from
> its delegate.  Also, there is no "dealloc method where you dispose of
> the UIWebView", because that's done automatically when the view is
> popped off the navigation stack.


What object is asking as the web view's delegate? Typically that object also 
has an owning reference to the web view, so you likely already have a -dealloc 
method that releases the web view – just also set the delegate of the web view 
at that point.
--
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 noise in Cocoa (preferably fast)

2011-06-17 Thread Stephen Blinkhorn


On 17 Jun 2011, at 00:18, Uli Kusterer wrote:


On 17.06.2011, at 03:08, Ken Tozier wrote:

On Jun 16, 2011, at 12:34 PM, Stephen Blinkhorn wrote:
A quick test on a 2GHz iMac takes at least twice as long 4.5  
seconds to generate a 10,000 X 10,000 CGLayer of noise.


Stephen


Thanks. Difference could just be the processor. My laptop has a 2.4  
GHz core i5


Might also be the GPU. After all, CoreImage's whole point is that it  
runs on the GPU preferably, and frees the CPU up for other uses.


This is great for my purposes as I want to keep as much CPU power  
available for the main processing (audio app) and not consume it all  
in the GUI.


Saying that, I've found that the CPU requirements of the raw drawing  
code (even with relatively fast refresh rates of 20-25 FPS) pales into  
insignificance when compared to the objective-c messaging overhead of  
co-ordinating the redrawing. Cocoa seems to need to do a lot of leg  
work with respect to view drawing.


Anyway, glad I learnt all about CIImage!

Thanks,
Stephen




Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://groups.yahoo.com/group/mac-gui-dev/



___

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/stephen%40audiospillage.com

This email sent to step...@audiospillage.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


Making NSCache evict only unreferenced objects

2011-06-17 Thread Jens Alfke
I have what seems like an excellent use case for NSCache, only it doesn’t have 
quite the behavior I need. And I’m having trouble thinking of how to tweak it 
to get that behavior.

In a nutshell: I want the cache to evict only objects that have no other 
references to them. So as long as something else has retained an object, it 
will stay in the cache. Only when that reference has been released will the 
object become a candidate for eviction. (I’m not using GC since this code will 
need to run on iOS.)

[Basically this is a cache of database records, where the dictionary key is the 
primary key and the value is a parsed version of the row data. I want to cache 
these to minimize database calls. I also want to ensure that the value objects 
are unique, i.e. there is never more than one value object for a particular 
primary key. NSCache alone won’t let me do that, since if an object gets 
evicted when there are still references to it, on the next fetch of that key 
I’ll re-fetch the row even though it’s still in memory.]

It seems like I could do this with some combination of NSCache and a weak 
NSMapTable*, but I haven’t figured out how. For example, I could add every 
object to both the cache and the table, then consult both tables when fetching; 
but that way the cache would be equally likely to evict objects that still have 
references, which is a waste. Or I could add an object to the cache only when 
its last external reference is removed, but that would require overriding 
-retain and -release, which I’m loath to do.

—Jens

* I realize NSMapTable only removes freed objects when GC is enabled; but it’s 
pretty easy to make my value class’s -dealloc method remove the object from the 
table, which gives the same 
result.___

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: Making NSCache evict only unreferenced objects

2011-06-17 Thread Chris Hanson
On Jun 17, 2011, at 9:40 AM, Jens Alfke wrote:

> Basically this is a cache of database records, where the dictionary key is 
> the primary key and the value is a parsed version of the row data. I want to 
> cache these to minimize database calls. I also want to ensure that the value 
> objects are unique, i.e. there is never more than one value object for a 
> particular primary key.

Rather than reinventing all of this yourself, you should just use Core Data.

It provides both the uniquing and the database call minimization you're looking 
for, and a lot else besides.

  -- Chris

___

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: Making NSCache evict only unreferenced objects

2011-06-17 Thread Jens Alfke

On Jun 17, 2011, at 11:28 AM, Chris Hanson wrote:

> Rather than reinventing all of this yourself, you should just use Core Data.
> It provides both the uniquing and the database call minimization you're 
> looking for, and a lot else besides.

This is for an Objective-C API to CouchDB, not to sqlite.

(And yes, I have the Lion and iOS 5 SDKs and know about new features under NDA 
that we can’t talk about here.)

—Jens___

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 Using StandardLibrary in XCode

2011-06-17 Thread Alex Flecher
Hi,

I am working on a kext based on SoundFlower and have used the source from
http:[//]anonymous@soundflower [dot] googlecode [dot] com[/]svn

However i am not able to use the standard c++ library. The compiler throws error
#include gives error-> iostream: no such file or directory.
However if i create a new c++ based project from template, it works fine.

i have selected compile source as c++ also and the build results log shows
gcc-4.0 -x c++ also. still the  is not accessible.
here is Build Result that i get:
CompileC 
build/Soundflower.build/Development/SoundflowerDriver.build/Objects-normal/i386/SoundflowerEngine.o
/Users/alexflecher/svnrepos/soundflower_svn/Source/SoundflowerEngine.cpp
normal i386 c++ com.apple.compilers.gcc.4_0
cd /Users/alexflecher/svnrepos/soundflower_svn/Source
/Developer/usr/bin/gcc-4.0 -x c++ -arch i386 -fmessage-length=0
-pipe -nostdinc -fno-builtin -Wno-trigraphs -fno-exceptions -fno-rtti
-fcheck-new -fasm-blocks -force_cpusubtype_ALL -static -msoft-float
-O0 -fno-common -mkernel -finline -fno-keep-inline-functions -DDEBUG
-DKERNEL -DKERNEL_PRIVATE -DDRIVER_PRIVATE -DAPPLE -DNeXT -isysroot
/Developer/SDKs/MacOSX10.4u.sdk -fapple-kext -mfix-and-continue
-mmacosx-version-min=10.4 -gdwarf-2
-I/Users/alexflecher/svnrepos/soundflower_svn/Source/build/Soundflower.build/Development/SoundflowerDriver.build/Soundflower.hmap
-Wmost -Wno-four-char-constants -Wno-unknown-pragmas
-F/Users/alexflecher/svnrepos/soundflower_svn/Source/build/Development
-I/Users/alexflecher/svnrepos/soundflower_svn/Source/build/Development/include
-I/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/backward
-I/System/Library/Frameworks/Kernel.framework/PrivateHeaders
-I/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Kernel.framework/Headers
-I/Users/alexflecher/svnrepos/soundflower_svn/Source/build/Soundflower.build/Development/SoundflowerDriver.build/DerivedSources/i386
-I/Users/alexflecher/svnrepos/soundflower_svn/Source/build/Soundflower.build/Development/SoundflowerDriver.build/DerivedSources
-c /Users/alexflecher/svnrepos/soundflower_svn/Source/SoundflowerEngine.cpp
-o 
/Users/alexflecher/svnrepos/soundflower_svn/Source/build/Soundflower.build/Development/SoundflowerDriver.build/Objects-normal/i386/SoundflowerEngine.o
/Users/alexflecher/svnrepos/soundflower_svn/Source/SoundflowerEngine.cpp:22:20:
error: iostream: No such file or directory

Can anybody tell why is XCode showing the error??

Thanks
Alex
___

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


Weird Crash in

2011-06-17 Thread Laurent Daudelin
One of my user sent me a crash log with an excerpt here:

...
Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0027
...
Thread 4 Crashed:  Dispatch queue: com.apple.root.default-priority
0   libobjc.A.dylib 0x7fff85ea115c objc_msgSend_vtable2 
+ 12
1   com.apple.Foundation0x7fff827f79a5 -[NSCFString 
isEqualToString:] + 63
...

It's a part of my code that compares NSStrings. Of course, nobody besides him 
are able to reproduce this.

My question: what could cause a crash in function 'objc_msgSend_vtable2'?

Thanks in advance!

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.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: Problem Using StandardLibrary in XCode

2011-06-17 Thread Kyle Sluder
Your question is not related to Cocoa. You should either ask on the
xcode-users forum, or in a forum related to SoundFlower.

--Kyle Sluder

On Fri, Jun 17, 2011 at 2:31 PM, Alex Flecher  wrote:
> Hi,
>
> I am working on a kext based on SoundFlower and have used the source from
> http:[//]anonymous@soundflower [dot] googlecode [dot] com[/]svn
>
> However i am not able to use the standard c++ library. The compiler throws 
> error
> #include gives error-> iostream: no such file or directory.
> However if i create a new c++ based project from template, it works fine.
>
> i have selected compile source as c++ also and the build results log shows
> gcc-4.0 -x c++ also. still the  is not accessible.
> here is Build Result that i get:
> CompileC 
> build/Soundflower.build/Development/SoundflowerDriver.build/Objects-normal/i386/SoundflowerEngine.o
> /Users/alexflecher/svnrepos/soundflower_svn/Source/SoundflowerEngine.cpp
> normal i386 c++ com.apple.compilers.gcc.4_0
>    cd /Users/alexflecher/svnrepos/soundflower_svn/Source
>    /Developer/usr/bin/gcc-4.0 -x c++ -arch i386 -fmessage-length=0
> -pipe -nostdinc -fno-builtin -Wno-trigraphs -fno-exceptions -fno-rtti
> -fcheck-new -fasm-blocks -force_cpusubtype_ALL -static -msoft-float
> -O0 -fno-common -mkernel -finline -fno-keep-inline-functions -DDEBUG
> -DKERNEL -DKERNEL_PRIVATE -DDRIVER_PRIVATE -DAPPLE -DNeXT -isysroot
> /Developer/SDKs/MacOSX10.4u.sdk -fapple-kext -mfix-and-continue
> -mmacosx-version-min=10.4 -gdwarf-2
> -I/Users/alexflecher/svnrepos/soundflower_svn/Source/build/Soundflower.build/Development/SoundflowerDriver.build/Soundflower.hmap
> -Wmost -Wno-four-char-constants -Wno-unknown-pragmas
> -F/Users/alexflecher/svnrepos/soundflower_svn/Source/build/Development
> -I/Users/alexflecher/svnrepos/soundflower_svn/Source/build/Development/include
> -I/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/backward
> -I/System/Library/Frameworks/Kernel.framework/PrivateHeaders
> -I/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Kernel.framework/Headers
> -I/Users/alexflecher/svnrepos/soundflower_svn/Source/build/Soundflower.build/Development/SoundflowerDriver.build/DerivedSources/i386
> -I/Users/alexflecher/svnrepos/soundflower_svn/Source/build/Soundflower.build/Development/SoundflowerDriver.build/DerivedSources
> -c /Users/alexflecher/svnrepos/soundflower_svn/Source/SoundflowerEngine.cpp
> -o 
> /Users/alexflecher/svnrepos/soundflower_svn/Source/build/Soundflower.build/Development/SoundflowerDriver.build/Objects-normal/i386/SoundflowerEngine.o
> /Users/alexflecher/svnrepos/soundflower_svn/Source/SoundflowerEngine.cpp:22:20:
> error: iostream: No such file or directory
>
> Can anybody tell why is XCode showing the error??
>
> Thanks
> Alex
> ___
>
> 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/kyle.sluder%40gmail.com
>
> This email sent to kyle.slu...@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: Weird Crash in

2011-06-17 Thread Greg Parker
On Jun 17, 2011, at 2:40 PM, Laurent Daudelin wrote:
> One of my user sent me a crash log with an excerpt here:
> 
> ...
> Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
> Exception Codes: KERN_INVALID_ADDRESS at 0x0027
> ...
> Thread 4 Crashed:  Dispatch queue: com.apple.root.default-priority
> 0   libobjc.A.dylib   0x7fff85ea115c objc_msgSend_vtable2 
> + 12
> 1   com.apple.Foundation  0x7fff827f79a5 -[NSCFString 
> isEqualToString:] + 63
> ...
> 
> It's a part of my code that compares NSStrings. Of course, nobody besides him 
> are able to reproduce this.
> 
> My question: what could cause a crash in function 'objc_msgSend_vtable2'?

Short answer: for any of the same reasons that cause a crash in objc_msgSend(). 

The vtable versions of objc_msgSend() are specialized optimizations for a few 
of the most frequently-called methods. objc_msgSend_vtable2 is currently 
optimizing the -class method. Presumably one of the two string objects was 
invalid and -isEqualToString: was trying to check which class the bad object 
belonged to.


-- 
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: Weird Crash in

2011-06-17 Thread Laurent Daudelin
On Jun 17, 2011, at 15:22, Greg Parker wrote:

> On Jun 17, 2011, at 2:40 PM, Laurent Daudelin wrote:
>> One of my user sent me a crash log with an excerpt here:
>> 
>> ...
>> Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
>> Exception Codes: KERN_INVALID_ADDRESS at 0x0027
>> ...
>> Thread 4 Crashed:  Dispatch queue: com.apple.root.default-priority
>> 0   libobjc.A.dylib  0x7fff85ea115c objc_msgSend_vtable2 
>> + 12
>> 1   com.apple.Foundation 0x7fff827f79a5 -[NSCFString 
>> isEqualToString:] + 63
>> ...
>> 
>> It's a part of my code that compares NSStrings. Of course, nobody besides 
>> him are able to reproduce this.
>> 
>> My question: what could cause a crash in function 'objc_msgSend_vtable2'?
> 
> Short answer: for any of the same reasons that cause a crash in 
> objc_msgSend(). 
> 
> The vtable versions of objc_msgSend() are specialized optimizations for a few 
> of the most frequently-called methods. objc_msgSend_vtable2 is currently 
> optimizing the -class method. Presumably one of the two string objects was 
> invalid and -isEqualToString: was trying to check which class the bad object 
> belonged to.

Thanks for the speedy reply, Greg. What do you mean exactly by "invalid"? Bad 
pointers? Pointers on instances of different classes? Or both?

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.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: Weird Crash in

2011-06-17 Thread Greg Parker

On Jun 17, 2011, at 3:48 PM, Laurent Daudelin wrote:

> On Jun 17, 2011, at 15:22, Greg Parker wrote:
> 
>> On Jun 17, 2011, at 2:40 PM, Laurent Daudelin wrote:
>>> One of my user sent me a crash log with an excerpt here:
>>> 
>>> ...
>>> Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
>>> Exception Codes: KERN_INVALID_ADDRESS at 0x0027
>>> ...
>>> Thread 4 Crashed:  Dispatch queue: com.apple.root.default-priority
>>> 0   libobjc.A.dylib 0x7fff85ea115c objc_msgSend_vtable2 
>>> + 12
>>> 1   com.apple.Foundation0x7fff827f79a5 -[NSCFString 
>>> isEqualToString:] + 63
>>> ...
>>> 
>>> It's a part of my code that compares NSStrings. Of course, nobody besides 
>>> him are able to reproduce this.
>>> 
>>> My question: what could cause a crash in function 'objc_msgSend_vtable2'?
>> 
>> Short answer: for any of the same reasons that cause a crash in 
>> objc_msgSend(). 
>> 
>> The vtable versions of objc_msgSend() are specialized optimizations for a 
>> few of the most frequently-called methods. objc_msgSend_vtable2 is currently 
>> optimizing the -class method. Presumably one of the two string objects was 
>> invalid and -isEqualToString: was trying to check which class the bad object 
>> belonged to.
> 
> Thanks for the speedy reply, Greg. What do you mean exactly by "invalid"? Bad 
> pointers? Pointers on instances of different classes? Or both?


Pointer to anything that is not a valid object. Merely being an instance of the 
wrong class would not cause that crash.


-- 
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: Drawing noise in Cocoa (preferably fast)

2011-06-17 Thread Stephen Blinkhorn


On 17 Jun 2011, at 10:30, Stephen Blinkhorn wrote:

Saying that, I've found that the CPU requirements of the raw drawing  
code (even with relatively fast refresh rates of 20-25 FPS) pales  
into insignificance when compared to the objective-c messaging  
overhead of co-ordinating the redrawing. Cocoa seems to need to do a  
lot of leg work with respect to view drawing.


Just to clarify that last sentence. I'm referring to the CPU  
requirements of drawing relatively simple graphics e.g. bezier paths,  
filled rects and some CGLayers (not 10,000 X 10,000 areas of noise!).


Stephen




Anyway, glad I learnt all about CIImage!

Thanks,
Stephen




Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://groups.yahoo.com/group/mac-gui-dev/



___

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/stephen%40audiospillage.com

This email sent to step...@audiospillage.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/stephen%40audiospillage.com

This email sent to step...@audiospillage.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: Weird Crash in

2011-06-17 Thread Laurent Daudelin
On Jun 17, 2011, at 15:51, Greg Parker wrote:

> On Jun 17, 2011, at 3:48 PM, Laurent Daudelin wrote:
> 
>> On Jun 17, 2011, at 15:22, Greg Parker wrote:
>> 
>>> On Jun 17, 2011, at 2:40 PM, Laurent Daudelin wrote:
 One of my user sent me a crash log with an excerpt here:
 
 ...
 Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
 Exception Codes: KERN_INVALID_ADDRESS at 0x0027
 ...
 Thread 4 Crashed:  Dispatch queue: com.apple.root.default-priority
 0   libobjc.A.dylib0x7fff85ea115c objc_msgSend_vtable2 
 + 12
 1   com.apple.Foundation   0x7fff827f79a5 -[NSCFString 
 isEqualToString:] + 63
 ...
 
 It's a part of my code that compares NSStrings. Of course, nobody besides 
 him are able to reproduce this.
 
 My question: what could cause a crash in function 'objc_msgSend_vtable2'?
>>> 
>>> Short answer: for any of the same reasons that cause a crash in 
>>> objc_msgSend(). 
>>> 
>>> The vtable versions of objc_msgSend() are specialized optimizations for a 
>>> few of the most frequently-called methods. objc_msgSend_vtable2 is 
>>> currently optimizing the -class method. Presumably one of the two string 
>>> objects was invalid and -isEqualToString: was trying to check which class 
>>> the bad object belonged to.
>> 
>> Thanks for the speedy reply, Greg. What do you mean exactly by "invalid"? 
>> Bad pointers? Pointers on instances of different classes? Or both?
> 
> 
> Pointer to anything that is not a valid object. Merely being an instance of 
> the wrong class would not cause that crash.

Thanks for that valuable information, Greg. At least I know where to look.

Cheers!

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.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: Drawing noise in Cocoa (preferably fast)

2011-06-17 Thread Scott Ellsworth
That seems a bit strange - have you put the code up somewhere?

Scott

On Fri, Jun 17, 2011 at 4:24 PM, Stephen Blinkhorn
 wrote:
>
> On 17 Jun 2011, at 10:30, Stephen Blinkhorn wrote:
>
>> Saying that, I've found that the CPU requirements of the raw drawing code
>> (even with relatively fast refresh rates of 20-25 FPS) pales into
>> insignificance when compared to the objective-c messaging overhead of
>> co-ordinating the redrawing. Cocoa seems to need to do a lot of leg work
>> with respect to view drawing.
>
> Just to clarify that last sentence. I'm referring to the CPU requirements of
> drawing relatively simple graphics e.g. bezier paths, filled rects and some
> CGLayers (not 10,000 X 10,000 areas of noise!).
>
> Stephen
>
>
>>
>> Anyway, glad I learnt all about CIImage!
>>
>> Thanks,
>> Stephen
>>
>>
>>>
>>> Cheers,
>>> -- Uli Kusterer
>>> "The Witnesses of TeachText are everywhere..."
>>> http://groups.yahoo.com/group/mac-gui-dev/
>>>
>>>
>>>
>>> ___
>>>
>>> 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/stephen%40audiospillage.com
>>>
>>> This email sent to step...@audiospillage.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/stephen%40audiospillage.com
>>
>> This email sent to step...@audiospillage.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/scott_ellsworth%40alumni.hmc.edu
>
> This email sent to scott_ellswo...@alumni.hmc.edu
>
___

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


Branch: Drawing noise in Cocoa (preferably fast)

2011-06-17 Thread Ken Tozier
Keying off Stephen's idea of drawing noise quickly, I came up with a solution 
that I can use for my own purposes. It seems like splitting up large image 
manipulations for execution on different processor cores could be a good 
introduction to GCD and blocks. I read the intro to GCD docs but am still a 
little in the dark about the whole topic. For example, say I'm using the 
following method to generate 10,000 x 10,000 or 50,000 x 50,000 pixel images, 
how would I go about "blockifying" it for GCD? 

#define RGB_BYTES_PER_PIXEL 3

- (CGImageRef) noiseImageRefWithBaseRed:(float) inRed
green:(float) inGreen
blue:(float) inBlue
width:(NSUInteger) inWidth
height:(NSUInteger) inHeight
{
NSUInteger  resultSize  = RGB_BYTES_PER_PIXEL * inWidth 
* inHeight;

// used to preserve the basic hue of the input color
float   clipPercent = 4.0/10;   

// convert input color floats to 8 bit ints
unsigned char   *buffer = (unsigned char *) malloc(resultSize),
*pr = buffer,
*pg = pr + 1,
*pb = pg + 1,
*e  = pr + 
resultSize,
r   = (inRed * 255),
g   = (inGreen * 
255),
b   = (inBlue * 
255),
redOffset,
greenOffset,
blueOffset,
noise;

// seed the random function
srandom(time(0));

// To preserve the basic hue of the input color,
// clip offsets of non-major colors by a fixed amount
if ((r > g) && (r > b))
{
redOffset   = 0;
greenOffset = (r - g) - (r - g) * clipPercent;
blueOffset  = (r - b) - (r - b) * clipPercent;
}
else if ((g > r) && (g > b))
{
greenOffset = 0;
redOffset   = (g - r) - (g - r) * clipPercent;
blueOffset  = (g - b) - (g - b) * clipPercent;
}
else
{
blueOffset  = 0;
redOffset   = (b - r) - (b - r) * clipPercent;
greenOffset = (b - g) - (b - g) * clipPercent;
}


NSLog(@"starting noise loop");
while (pr < e)
{
noise   = random();

*pr = r + (noise % redOffset);  pr += 
RGB_BYTES_PER_PIXEL;
*pg = g + (noise % greenOffset);pg += 
RGB_BYTES_PER_PIXEL;
*pb = b + (noise & blueOffset); pb += 
RGB_BYTES_PER_PIXEL;
}
NSLog(@"noise loop complete");

// create data provider
CGDataProviderRef   imgDataProvider = 
CGDataProviderCreateWithData(NULL, buffer, resultSize, NULL);
CGColorSpaceRef imgColorSpace   = CGColorSpaceCreateDeviceRGB();
CGImageRef  img 
= CGImageCreate (

inWidth,

inHeight,

8,

RGB_BYTES_PER_PIXEL * 8,

RGB_BYTES_PER_PIXEL * inWidth,

imgColorSpace,

kCGImageAlphaNone,

imgDataProvider,

NULL,

true,
 

Re: Drawing noise in Cocoa (preferably fast)

2011-06-17 Thread Stephen Blinkhorn

On 17 Jun 2011, at 19:45, Scott Ellsworth wrote:


That seems a bit strange - have you put the code up somewhere?


No, not yet. I might post something here over the weekend. It's  
puzzled me a bit for a year or so off and on now.

Stephen




Scott

On Fri, Jun 17, 2011 at 4:24 PM, Stephen Blinkhorn
 wrote:


On 17 Jun 2011, at 10:30, Stephen Blinkhorn wrote:

Saying that, I've found that the CPU requirements of the raw  
drawing code

(even with relatively fast refresh rates of 20-25 FPS) pales into
insignificance when compared to the objective-c messaging overhead  
of
co-ordinating the redrawing. Cocoa seems to need to do a lot of  
leg work

with respect to view drawing.


Just to clarify that last sentence. I'm referring to the CPU  
requirements of
drawing relatively simple graphics e.g. bezier paths, filled rects  
and some

CGLayers (not 10,000 X 10,000 areas of noise!).

Stephen




Anyway, glad I learnt all about CIImage!

Thanks,
Stephen




Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://groups.yahoo.com/group/mac-gui-dev/



___

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/stephen%40audiospillage.com

This email sent to step...@audiospillage.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/stephen%40audiospillage.com

This email sent to step...@audiospillage.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/scott_ellsworth%40alumni.hmc.edu

This email sent to scott_ellswo...@alumni.hmc.edu



___

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: Temporarily enabling layer backing for NSView

2011-06-17 Thread Indragie Karunaratne
Super late reply here, but I just tried that and it still doesn't work. It 
seems to work every now and then randomly but other times it doesn't work at 
all. Sounds like some sort of timing issue.

On 2011-05-18, at 1:04 AM, Josh Abernathy wrote:

> Try doing the animation one runloop after calling -setWantsLayer:, kinda like 
> this (typed in Mail):
> 
> - (void)doAnimation {
>[parentView setWantsLayer:YES];
>[self performSelector:@selector(noSeriouslyDoTheAnimation) withObject:nil 
> afterDelay:0];
> }
> 
> - (void) noSeriouslyDoTheAnimation {
>CATransition *transition = [CATransition animation];
>transition.type = kCATransitionPush;
>transition.subtype = kCATransitionFromLeft;
>transition.timingFunction = [CAMediaTimingFunction 
> functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
>[CATransaction begin];
>[CATransaction setCompletionBlock:^(void) {
>   [parentView setWantsLayer:NO];
>}];
>[parentView setAnimations:[NSDictionary dictionaryWithObject:transition 
> forKey:@"subviews"]];
>[[parentView animator] replaceSubview:firstView with:secondView];
>[CATransaction commit];
> }
> 
> 
> On May 17, 2011, at 7:59 PM, Indragie Karunaratne wrote:
> 
>> Hi all,
>> 
>> I'm trying to use CATransition in my app to provide an animated slide 
>> transition when swapping views. I don't want to permanently layer back my 
>> views because they cause various glitches (no subpixel antialiasing, resize 
>> issues when backed with a CATiledLayer, etc.) To get around this, I want to 
>> temporarily layer back my view, run the animation, and then disable layer 
>> backing after the animation completes. This is my code thus far:
>> 
>> CATransition *transition = [CATransition animation];
>> transition.type = kCATransitionPush;
>> transition.subtype = kCATransitionFromLeft;
>> transition.timingFunction = [CAMediaTimingFunction 
>> functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
>> [parentView setWantsLayer:YES];
>> [CATransaction begin];
>> [CATransaction setCompletionBlock:^(void) {
>>   [parentView setWantsLayer:NO];
>> }];
>> [parentView setAnimations:[NSDictionary dictionaryWithObject:transition 
>> forKey:@"subviews"]];
>> [[parentView animator] replaceSubview:firstView with:secondView];
>> [CATransaction commit];
>> 
>> With this code, the animation doesn't run (the views just get swapped 
>> without animation but the completion block is still called). The problem 
>> seems to be the fact that I'm calling -setWantsLayer: immediately before the 
>> animation begins. If I call this method in -awakeForNib, the animation will 
>> run. I'm thinking that this might be some sort of runloop issue, but I have 
>> no idea what I can do to work around this. I've tried moving my 
>> -setWantsLayer: call to various places within the animation method but this 
>> has no effect.
>> 
>> Any help is greatly appreciated.
>> Thanks,
>> Indragie
>> 
>> http://indragie.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/joshaber%40gmail.com
>> 
>> This email sent to josha...@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


Writing extremely large RTF or .doc files

2011-06-17 Thread Dave DeLong
Hey List,

I'm writing a little app for myself to take a database full of text and format 
it into either a Word Document or an RTF document (either one is fine for my 
purposes).  I've got it working for small datasets, but I'm running in to 
performance issues when trying to generate files larger than a couple of 
megabytes.

Ideally, I'd like to create my thousands and thousands of NSAttributedStrings, 
convert them to NSData objects, and stream them out to disk.  Unfortunately, 
the APIs in AppKit require me to build a single NSAttributedString and convert 
it into an NSData all at once; no streaming is possible.  For my purposes, this 
is impractical because of the memory implications of keeping tens of thousands 
of NSAttributedStrings alive for the duration of the generation process.

The only thought I had to work around this was to generate my RTF data and 
strip out the document-level attributes before streaming it out to disk.  
Barring a superior solution, I'll end up doing this.

I surely can't be the first person to want to do  this, so I ask: what have I 
missed?  How can I generate extremely large rich-text files without having to 
build the entire file in memory before writing it out?

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: Writing extremely large RTF or .doc files

2011-06-17 Thread Ken Tozier
Is there some reason the text needs to be RTF? Is it just that you want to view 
this text formatted nicely at a future date? Or do you plan on distributing the 
monster RTF?

If it's just nicely formatted text you're after would HTML with CSS serve just 
as well? If so, you could write an aggregator that did something like the 
following:

- Write HTML head with CSS to dest file
- Query DB for next piece of text
- NSData*chunk  = [[NSStringWithFormat: @"%@%@", chunkHeaderString, chunkBodyString] 
dataUsingEncoding: NSUTF*StringEncoding];
- [fileHandle writeData: chunk]
- write  and  close tags to the end of the file

Done.



 
On Jun 18, 2011, at 12:43 AM, Dave DeLong wrote:

> Hey List,
> 
> I'm writing a little app for myself to take a database full of text and 
> format it into either a Word Document or an RTF document (either one is fine 
> for my purposes).  I've got it working for small datasets, but I'm running in 
> to performance issues when trying to generate files larger than a couple of 
> megabytes.
> 
> Ideally, I'd like to create my thousands and thousands of 
> NSAttributedStrings, convert them to NSData objects, and stream them out to 
> disk.  Unfortunately, the APIs in AppKit require me to build a single 
> NSAttributedString and convert it into an NSData all at once; no streaming is 
> possible.  For my purposes, this is impractical because of the memory 
> implications of keeping tens of thousands of NSAttributedStrings alive for 
> the duration of the generation process.
> 
> The only thought I had to work around this was to generate my RTF data and 
> strip out the document-level attributes before streaming it out to disk.  
> Barring a superior solution, I'll end up doing this.
> 
> I surely can't be the first person to want to do  this, so I ask: what have I 
> missed?  How can I generate extremely large rich-text files without having to 
> build the entire file in memory before writing it out?
> 
> 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/kentozier%40comcast.net
> 
> This email sent to kentoz...@comcast.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: Writing extremely large RTF or .doc files

2011-06-17 Thread Dave DeLong

On Jun 17, 2011, at 10:15 PM, Ken Tozier wrote:

> Is there some reason the text needs to be RTF? Is it just that you want to 
> view this text formatted nicely at a future date? Or do you plan on 
> distributing the monster RTF?

It needs to be editable after the fact.

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: Writing extremely large RTF or .doc files

2011-06-17 Thread Ken Tozier

On Jun 18, 2011, at 1:18 AM, Dave DeLong wrote:

> It needs to be editable after the fact.
> 
> Dave
> 

It is. If you open such a file in Word, it just looks like styled text. You can 
edit it and save it as html or RTF. Whichever you prefer. Try saving the 
following to a plain text file, open it in Word, and voila! Editable, styled 
text file.




Word edit test


.chunkHeader
{
font-family: Lucida Grande, Gill Sans, Arial, 
Helvetica, Geneva, Swiss, SunSans-Regular;
font-size: 14px;
font-weight: bold;
}

.chunkBody
{
font-family: Lucida Grande, Gill Sans, Arial, 
Helvetica, Geneva, Swiss, SunSans-Regular;
font-size: 12px;
font-weight: normal;
}
 


Header 1
Lorem ipsum dolor sit amet, consectetuer 
adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore 
magna aliquam erat volutpat.
Header 2
Duis autem vel eum iriure dolor in 
hendrerit in vulputate velit esse molestie consequat.





___

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: Writing extremely large RTF or .doc files

2011-06-17 Thread Dave DeLong
Fair enough. This is certainly a great alternative to stripping out the 
document level attributes, but I'd still prefer the format to be as "native" as 
possible. Using HTML like this feels a bit kludgey. 

Dave

Sent from my iPhone

On Jun 17, 2011, at 10:45 PM, Ken Tozier  wrote:

> 
> On Jun 18, 2011, at 1:18 AM, Dave DeLong wrote:
> 
>> It needs to be editable after the fact.
>> 
>> Dave
>> 
> 
> It is. If you open such a file in Word, it just looks like styled text. You 
> can edit it and save it as html or RTF. Whichever you prefer. Try saving the 
> following to a plain text file, open it in Word, and voila! Editable, styled 
> text file.
> 
> 
>
>
>Word edit test
>
>
>.chunkHeader
>{
>font-family: Lucida Grande, Gill Sans, Arial, Helvetica, 
> Geneva, Swiss, SunSans-Regular;
>font-size: 14px;
>font-weight: bold;
>}
>
>.chunkBody
>{
>font-family: Lucida Grande, Gill Sans, Arial, Helvetica, 
> Geneva, Swiss, SunSans-Regular;
>font-size: 12px;
>font-weight: normal;
>}
> 
>
>
>Header 1
>Lorem ipsum dolor sit amet, consectetuer 
> adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore 
> magna aliquam erat volutpat.
>Header 2
>Duis autem vel eum iriure dolor in hendrerit in 
> vulputate velit esse molestie consequat.
>
> 
> 
> 
> 
> ___
> 
> 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/archive%40mail-archive.com

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


Release a NSWindowController after the window is closed

2011-06-17 Thread Brian Norh
Hello.

I'm building a Cocoa application and have a question about using
window controllers. The idea is that when the user selects New from
the File menu, an instance of MyWindowController which is a subclass
of NSWindowController is created and a new window from MyWindow.xib is
displayed.

I'm handling the action in the application delegate. From what I have
seen after searching around something like the following could be
done. Once the window is displayed I don't have any reason to store a
pointer to the window controller anymore and since I allocated it I
also have it autoreleased before displaying the window.

MyWindowController alloc] init] autorelease] showWindow:self];

Since the window is released soon afterwards the window will briefly
display on the screen and then go away. I'm using a solution where I
retain the window controller in the -showWindow: method and let it
release itself once it gets a windowWillClose notification.

- (IBAction)showWindow:(id)sender
{
void (^windowWillCloseHandler)(NSNotification *) = ^(NSNotification *note) {
[[NSNotificationCenter defaultCenter] removeObserver:self
name:NSWindowWillCloseNotification object:self.window];
[self release];
};

[self retain];
[[NSNotificationCenter defaultCenter]
addObserverForName:NSWindowWillCloseNotification object:self.window
queue:nil usingBlock:windowWillCloseHandler];
[super showWindow:sender];
}

Is there a better way to do this? I have searched the documentation
and have not found anything specific on which practices to use. It
sounds like something very basic which it should cover so maybe I'm
just searching with the wrong terms.

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


EXC_BAD_ACCESS searching PDF

2011-06-17 Thread Piero Campanelli

___

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: After Autoreleasing Still Getting Leaked

2011-06-17 Thread Marcus Karlsson

On Jun 16, 2011, at 12:33 PM, Bing Li wrote:

> Dear Conrad, Jens, Tony, Scott, Wade and all,
> 
> I appreciate so much for your replies. I learn a lot from the interactions
> with you. Since I am new, your patience is so valuable to me!
> 
> I just got the problem. At least, right now, there is no the leak. When
> receiving messages, I put them into a queue. However, I forgot implementing
> a dealloc for it and I also did not release it when the connection was
> disconnected. After the bug was fixed, the leaking issue was solved.

Well done.

> But I still have a question. The queue is actually derived from NSArray. It
> should be empty after when the connection was disconnected. Why was there
> such a huge leak?

In your snippet that you sent earlier you allocated memory in an infinite loop. 
It's not uncommon that such loops keeps going for a large number of iterations 
when things goes wrong. Even if you leak just a little bit of data for each 
iteration, the sum of leaked memory can become very big.

> For the TCP issues, I planned to change my current solution. I will send the
> length of the buffer first and then send the real data. I have ever done
> that on .NET. The difference is that this time I need to exchange messages
> among different OSs (Java/Linux and iOS). So XML is used. On .NET, I just
> use its serialization technique. I am not sure if I need to consider little
> endian/big endian issues? My iMac is an Intel CPU. I don't need to do that,
> right? What about iPad/iPhone?

It's not uncommon that network protocols have the length included somewhere in 
the beginning. But it's not a bullet-proof solution and you still have to 
handle the possibility of getting fragmented data. If you're not dealing with 
persistent connections then maybe an even simpler approach could be to just 
keep reading until he remote socket is closed.

XML is already encoded so you don't need to convert it according to endianness. 
It's only when you're transmitting raw bytes directly over the network when you 
need to do that. As long as you have defined your protocol and how you encode 
and decode the transmitted data it doesn't matter which operating system or CPU 
architecture is on each end. The serialization you've used earlier is just one 
way of doing that. In the end it's just bits that goes over the wire, whether 
it's XML or your own binary format doesn't matter.

> When implementing multi-threading, NSOperationQueue is used in my system. I
> don't create threads explicitly unless in some specific cases, for example,
> a streaming control thread pool.
> 
> The major reason I intend to use sockets is that I attempt to design a P2P
> communication protocol when transmitting data over the Internet. I also did
> that successfully on .NET. I think a controllable socket is more flexible
> although its programming is difficult a little bit.

I'm not particularly familiar with NSOperationQueue and don't know how well it 
works for network operations. I often use the CFNetwork API:s which I recommend 
that you take a look at.

> I will learn Cocoa programming continually and carefully. Thanks so much for
> your help again!
> 
> Best regards,
> Bing
> 
> 
> 
> On Thu, Jun 16, 2011 at 4:10 AM, Conrad Shultz <
> con...@synthetiqsolutions.com> wrote:
> 
>> -BEGIN PGP SIGNED MESSAGE-
>> Hash: SHA1
>> 
>> On 6/15/11 12:50 PM, Bing Li wrote:
>>> Jens,
>>> 
>>> Thanks so much for your suggestions!
>>> 
>>> I wonder why it works fine according to Activity Monitor if such a huge
>> leak
>>> exists. The consumed memory in the Activity Monitor is stable and much
>>> smaller unless some threads are created at a high concurrent moment.
>> After
>>> the threads are dead, the consumed memory becomes stable and small. I
>> feel
>>> weird for this.
>> 
>> Honestly, I feel like you are not listening to the excellent responses
>> people are giving you.
>> 
>> 1) Activity Monitor is not a profiling tool.  Don't use it as such.  Use
>> Leaks/Allocations, maybe with some heapshot analysis thrown in as I
>> believe I mentioned a while back.
>> 
>> 2) Analyze your code with the Clang static analyzer ("Build & Analyze").
>> This will shake out many common memory issues (and more).
>> 
>> 3) Recognize that posting snippets of the code that you THINK might be
>> responsible for a leak does not mean that people on the list can
>> actually help you find it.  For example, even if you are doing
>> everything completely properly inside a function, if that function
>> returns some object, the calling code can still leak that object.
>> 
>> 4) It seems as if much of your code is multi-threaded.  All else being
>> equal, this makes such problems even harder to debug.  If I were having
>> such serious issues, I would probably spend some time trying to get the
>> task to work on the main thread and only once that is thoroughly
>> debugged would I break it up across threads.  (This won't work for every
>> type of problem, but if it can work 

Tab Bar iPad App With Table View (Please help, been trying all day)

2011-06-17 Thread Julie Seif
Hi,

I want to create a Tab Bar based iPad App. I would like it so that you tap
on one of the tab bar buttons and a Table View comes up in the view area for
that button as a Navigation Menu, you would tap the table cell to get to
whatever media/etc is attached to that cell in the table. (Imagine the Apple
Inc. iPhone Music app, the way the tab bar and the table is set up for that)

How would I go about doing this? (Note: I'm an absolute newbie)

I do not have any idea how to produce a tab bar application that does this.
Any help would be appreciated, I've been trying all day.

Thanks!
Julie.
___

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