Re: Invalidating UIImageView's image cache

2020-09-22 Thread Eric Lee via Cocoa-dev
Ah maybe it is the use of `imageNamed:`.  I believe that caches the image data 
in a system cache.  Have you tried `imageWithContentsOfFile:`?

https://developer.apple.com/documentation/uikit/uiimage/1624123-imagewithcontentsoffile

> On Sep 22, 2020, at 16:56, Carl Hoefs  wrote:
> 
> 
>> On Sep 22, 2020, at 1:46 PM, Eric Lee via Cocoa-dev 
>>  wrote:
>> 
>>> I don't have a good answer, but I think this may be more that UIImage 
>>> caches the images, not UIImageView. Maybe you can find something in 
>>> UIImage's docs/headers?
>> 
>> I think you may be on to something.  This WWDC 
>> <https://developer.apple.com/videos/play/wwdc2018/219> session covers 
>> optimizing UIImage performance and has some info on what UIImage caches.
>> 
>> How are you creating the UIImage?  Are you retaining the UIImage anywhere 
>> outside of the UIImageView? 
> 
> 
> The path of UIImage creation is as follows:
> 
> - For each manually-initiated processing pass of the app, a standard set of 
> 12 JPG files is written to the sandbox using the OpenCV::imwrite() function, 
> which creates a JPG from data values. The files have fixed filenames.
> 
> - When all 12 JPG files for a pass are written, I then use the following code 
> snippet to create the UIImages and display them on the main UIImageView:
> 
>NSMutableArray *uiImagesArray = [NSMutableArray new];
>for (NSString *file in [[NSFileManager defaultManager] 
> contentsOfDirectoryAtPath:self.sandboxPath error:NULL]) {
>if ([file.pathExtension isEqualToString:@"jpg"]) {
>UIImage *tempImage = [UIImage imageNamed:jpgFilename];
>if (tempImage) [uiImagesArray addObject:tempImage];
>}
>}
>UIImage *allAGFAImages = [UIImage animatedImageWithImages:uiImagesArray 
> duration:20.0];
>self.imageView.image = allAGFAImages;
> 
> - When a new pass of the app is run, the sandbox contents are deleted (see 
> below), the uiImagesArray variable is set to nil, and the new JPG files are 
> written, using the same filenames as before. Note that I do not set each 
> UIImage in the array explicitly to nil.
> 
>[[NSFileManager defaultManager] removeItemAtURL:[NSURL 
> fileURLWithPath:[self.sandboxPath stringByAppendingPathComponent:file]] 
> error:];
> 
> - If I add a uniquing string to the filenames for each pass, the problem does 
> not present itself. Otherwise the original (old) cached image contents are 
> displayed until the app is restarted.
> 
> - I don't retain the UIImages anywhere other than adding them to the array in 
> the code snippet above.
> 
> -Carl
> 

___

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

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

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

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


Re: Invalidating UIImageView's image cache

2020-09-22 Thread Eric Lee via Cocoa-dev


> I don't have a good answer, but I think this may be more that UIImage caches 
> the images, not UIImageView. Maybe you can find something in UIImage's 
> docs/headers?

I think you may be on to something.  This WWDC 
 session covers 
optimizing UIImage performance and has some info on what UIImage caches.

How are you creating the UIImage?  Are you retaining the UIImage anywhere 
outside of the UIImageView? 
___

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

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

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

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


NSTimer help

2008-12-17 Thread Eric Lee
I have an application, and when I exit the window, the timer doesn't  
stop, so the application freezes.


Is there something similar to -(void)awakeFromNib but for stopping a  
timer when a window closes?


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: NSTimer help

2008-12-17 Thread Eric Lee



Begin forwarded message:


From: Eric Lee ericlee1...@gmail.com
Date: December 17, 2008 3:02:40 PM CST
To: Ken Thomases k...@codeweavers.com
Subject: Re: NSTimer help

Thanks...i hadn't realized there was a  - 
(void)windowShouldClose..but now I have another problem.


I have implemented an if/else statement so that I can determine if  
something is happening


However, even though the if statement is true, the window never  
closes:


Here's the code...thanks

- (void)windowShouldClose:(id)window
{
if ([[textField stringValue] isEqualTo: @0:00:00 || @0.0 ]) {
[mainWindow windowShouldClose:YES];

}

else {

NSAlert *alert;
		alert = [NSAlert alertWithMessageText:@Error! defaultButton:nil  
alternateButton:nil otherButton:nil  
informativeTextWithFormat:@Please stop the timer.];


[alert runModal];

[mainWindow windowShouldClose:NO];
}
}


___

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

Please do not post admin requests or moderator comments to the list.
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: NSTimer help

2008-12-17 Thread Eric Lee



Begin forwarded message:


From: Eric Lee ericlee1...@gmail.com
Date: December 17, 2008 3:18:41 PM CST
To: Volker in Lists volker_li...@ecoobs.de
Subject: Re: NSTimer help

Ah...thanks

I had first started out with -(void)windowWillClose..and I guess I  
just forgot to change it..


Also, instead of [mainWindow windowShouldClose:NO/YES];, should i  
just put return NO/YES; ?


Thanks
On Dec 17, 2008, at 3:10 PM, Volker in Lists wrote:


Hi Eric,


- (BOOL)windowShouldClose:(id)window

is the correct implementation with the method name implicating a  
question that is answered either YES or NO. Your method in its  
current form is not called, which you could have easily worked out  
using a single NSLog(@I do work sometimes); within the method.


Cheers,
Volker


Am 17.12.2008 um 22:05 schrieb Eric Lee:




Begin forwarded message:


From: Eric Lee ericlee1...@gmail.com
Date: December 17, 2008 3:02:40 PM CST
To: Ken Thomases k...@codeweavers.com
Subject: Re: NSTimer help

Thanks...i hadn't realized there was a  - 
(void)windowShouldClose..but now I have another problem.


I have implemented an if/else statement so that I can determine  
if something is happening


However, even though the if statement is true, the window never  
closes:


Here's the code...thanks

- (void)windowShouldClose:(id)window
{
	if ([[textField stringValue] isEqualTo: @0:00:00 ||  
@0.0 ]) {

[mainWindow windowShouldClose:YES];

}

else {

NSAlert *alert;
		alert = [NSAlert alertWithMessageText:@Error!  
defaultButton:nil alternateButton:nil otherButton:nil  
informativeTextWithFormat:@Please stop the timer.];


[alert runModal];

[mainWindow windowShouldClose:NO];
}
}


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/volker_lists%40ecoobs.de

This email sent to volker_li...@ecoobs.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: Run Function At Intervals in Cocoa

2008-10-13 Thread Eric Lee

Check out NSTimer, NSTimeInterval, and NSRunLoop
On Oct 13, 2008, at 10:47 AM, Pierce Freeman wrote:

Hi everyone.  I am fairly new to Cocoa, so I apologize if this is a  
very

basic question (but after searching for awhile I still can't find an
answer).  Anyway, I am wondering how I can create a function that  
will run
at intervals.  What the function would do is scan which applications  
are

open, and then output a message to the user if there is a certain
application open (I have already created this part of it).  If  
anyone could

help, that would be great.


Thanks for all the help.


___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

Please do not post admin requests or moderator comments to the list.
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 [EMAIL PROTECTED]


Bindings Question

2008-09-25 Thread Eric Lee
I have an app that I'm making for practice that has a tableview, and a  
text field (and many other things, but the ones that are the problem  
are these two)


I just successfully changed my app to use bindings. However, whenever  
I pressed a button before, something would be added into a  
NSMutableArray, and then the string would show up in the table view.


Now, something IS added into the NSmutableArray, and will show up, but  
not the string. The thing that's added is just this blank.


How do you solves these so that when I press the button, the string in  
the text field will actually be added and shown in the table view?


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 [EMAIL PROTECTED]


Re: Bindings Question

2008-09-25 Thread Eric Lee

Sorry for the late response...computer froze

Anyways, yeah, I have a NSArrayController, and I binded the table view  
to it, which let me actually add something. How do you bind a button  
to an action? Just control-drag?

On Sep 25, 2008, at 7:39 PM, Chris Idou wrote:



Normally you would have the table controlled by a NSArrayController.  
You would bind the button to an action method which would take the  
value from the text field and pass it to addObject: method of the  
array controller.



--- On Thu, 9/25/08, Eric Lee [EMAIL PROTECTED] wrote:


From: Eric Lee [EMAIL PROTECTED]
Subject: Bindings Question
To: Cocoa-dev@lists.apple.com
Date: Thursday, September 25, 2008, 5:34 PM
I have an app that I'm making for practice that has a
tableview, and a
text field (and many other things, but the ones that are
the problem
are these two)

I just successfully changed my app to use bindings.
However, whenever
I pressed a button before, something would be added into a

NSMutableArray, and then the string would show up in the
table view.

Now, something IS added into the NSmutableArray, and will
show up, but
not the string. The thing that's added is just this
blank.

How do you solves these so that when I press the button,
the string in
the text field will actually be added and shown in the
table view?

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

This email sent to [EMAIL PROTECTED]




___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

Please do not post admin requests or moderator comments to the list.
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 [EMAIL PROTECTED]


NSDate/Tokens for Calendar Format String Question

2008-09-24 Thread Eric Lee
I have a problem. Basically, I want to take the time, and set the text  
field to that time, only the time with 12 Hours. How do you do 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 [EMAIL PROTECTED]


Re: NSDate/Tokens for Calendar Format String Question

2008-09-24 Thread Eric Lee

Wow...never saw that...can't believe it

Thanks! I'll look into it
On Sep 24, 2008, at 10:13 PM, Sean McBride wrote:


Eric Lee ([EMAIL PROTECTED]) on 2008-9-24 10:21 PM said:

I have a problem. Basically, I want to take the time, and set the  
text

field to that time, only the time with 12 Hours. How do you do this?


Have you read about NSDateFormatter?




___

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

Please do not post admin requests or moderator comments to the list.
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 [EMAIL PROTECTED]


Bindings Help

2008-09-23 Thread Eric Lee

I'm just beginning to learn bindings, and I havea  question.

Using bindings, how do you add an object (a textfield's string to be  
specific) to a NSMutableArray so that a table view can show the object?


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 [EMAIL PROTECTED]


How to load a window

2008-09-21 Thread Eric Lee
My question is simple (and probably basic from some of you  
experts :S). How do you load another window just by pressing a button?


On CocoaDevCentral, they say to use NSBundle, but I read on the  
documentation that you can also use NSWindowController?


Thanks for any help!
___

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

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

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

This email sent to [EMAIL PROTECTED]


NSTableView Protocol Help!

2008-09-04 Thread Eric Lee
So, I've written a practice application with NSTableView, and  
NSMutableArray. I have NSTableView connected to AppController as a  
dataSource, and I connected all outlets.


I have ALREADY defined the protocols needed, but for some reason, this  
message keeps on appearing in the debugger:


*** Illegal NSTableView data source (MyDocument: 0x167290).  Must  
implement numberOfRowsInTableView: and  
tableView:objectValueForTableColumn:row:


Here are the protocols that I have written:

___

- (void)tableView:(NSTableView *)anotherTableView
  setObjectValue:(id)anObject
  forTableColumn:(NSTableColumn *)anotherTableColumn
  row:(NSInteger)rowIndex
{
[mutableArray replaceObjectAtIndex:rowIndex withObject:anObject];
}

- (id)tableView:(NSTableView *)aTableView
  objectValueForTableColumn:(NSTableColumn *)aTableColumn
  row:(NSInteger)rowIndex
{
return [mutableArray objectAtIndex:rowIndex];
}

- (NSInteger)numberOfRowsInTableView:aTableView
{
return [splitViewMutableArray count];
}

___
Thanks for any help!!
___

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

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

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

This email sent to [EMAIL PROTECTED]


Protocol for Table View Trouble

2008-08-05 Thread Eric Lee
I've been having trouble implementing some protocols for table view. I  
just copied and pasted from my other code into this .m file, changed  
the variables so that it matched the variables in the .h file, but it  
has 6 errors, and I can't find out why!


Here's the .m file:

#import drawerTableView.h

@implementation drawerTableView

- (IBAction)makeDrawerVisible:(id)sender
{   
[drawer setLeadingOffset:0];
[drawer setTrailingOffset:0];
[drawer openOnEdge:1];

	[itunessongs initWithSource:@Users/ericlee/Desktop/Development/Watch/ 
getitunessongs.scpt];


[drawerTableView reloadData];
}

- (IBAction)makeDrawerGone:(id)sender
{
[drawer close];
}

- (NSInteger)numberOfRowsInTableView:aTableView
{
	if ([itunesArray isEqual:drawerTableView]) { //says there's a  
error:syntax error before 'drawerTableView'

return [itunesArray count];

}
return [itunesArray count]; //says error:syntax error before 'return'

}
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(NSInteger)rowIndex
{
	if ([itunesArray isEqual: drawerTableView]) {//says error:syntax  
error before 'drawerTableView'

return [itunesArray objectAtIndex:rowIndex];
}
	return [itunesArray objectAtIndex:rowIndex]; //says error:syntax  
error before 'return'


}

- (void)tableView:(NSTableView *)anotherTableView
   setObjectValue:(id)anObject
   forTableColumn:(NSTableColumn *)anotherTableColumn
  row:(NSInteger)rowIndex
{
	if ([itunesArray isEqual: drawerTableView]) { //says error: syntax  
error before 'drawerTableView'

[itunesArray replaceObjectAtIndex:rowIndex withObject:anObject];
}
} //says there's an error: syntax error before '}' token


@end

Thanks!

The problem parts are highlighted in green (sorry if you can't read  
it :( )

___

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

Please do not post admin requests or moderator comments to the list.
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 [EMAIL PROTECTED]


Re: How to get music list?

2008-08-04 Thread Eric Lee


On Aug 4, 2008, at 3:51 PM, has wrote:


Eric Lee wrote:


I have a problem getting the iTunes list, and then making the
tableview display the iTunes list.



Using objc-appscript [1], here's how to list the name, artist and  
album of every track in the current playlist:



#import ITGlue/ITGlue.h

// To create glue files: osaglue  -o ITGlue  -p IT  iTunes

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

	ITApplication *itunes = [ITApplication applicationWithBundleID:  
@com.apple.itunes];


ITReference *tracks = [[itunes currentPlaylist] tracks];

/* Note: if player is stopped then current playlist isn't available.
 * You could either test for this in advance (as shown here) or check
 * for nil results after sending the 'get' events. Additional NSError
 * info is also optionally available.
 */
if ([[[tracks exists] send] boolValue]) {

/*
 * Note: Apple event IPC is query-based, allowing you to get a
 * property from all elements at once. This is far quicker than
 * iterating over elements yourself if there are lots of them.
 */
NSArray *names = [[tracks name] getList];
NSArray *artists = [[tracks artist] getList];
NSArray *albums = [[tracks album] getList];

int i;
for (i = 0; i  [names count]; i++)
			printf(%-60s  %-60s  %-60s\n, [[names objectAtIndex: i]  
UTF8String],


[[artists objectAtIndex: i] UTF8String],

[[albums objectAtIndex: i] UTF8String]);

} else
printf(Current playlist is not available.\n);

[pool drain];
return 0;
}


HTH

has

[1] Which is a bit like Scripting Bridge, but without the  
application compatibility problems and with 10.3.9 and 10.4.x  
support, better documentation and developer tools.

--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.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 [EMAIL PROTECTED]


How to get music list?

2008-08-03 Thread Eric Lee
I have a problem getting the iTunes list, and then making the  
tableview display the iTunes list.


The problem, is actually getting started. Which class should I use?
___

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

Please do not post admin requests or moderator comments to the list.
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 [EMAIL PROTECTED]


NSSplitView question

2008-08-03 Thread Eric Lee
I have two table views with two different data, and I have two buttons  
so that when you press one button, something is added to the first  
table view, and when you press the second button, some info is added  
to the second table view. You can't press the 1st one to add it to the  
2nd table view.


So, here's my question. How do you have two table view's in the  
same .h/.m file? I try to reimplement the needed protocols, but I  
can't, so I then try to add the code to adding data to the same  
protocols that the 1st table view is implementing, but then, both  
table view's stop working!


Does anyone have any suggestions?
___

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

Please do not post admin requests or moderator comments to the list.
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 [EMAIL PROTECTED]


NSSplitView Question

2008-08-03 Thread Eric Lee
Sorry, I accidently did something wrong on that message. Here's the  
one I'm actually asking...



How do you make a NSSplitView so that when you click something on one  
side, the other side is updated. For example, take the mail  
application. When you click trash, the other side is updated to  
display the trash content, and when you press Inbox, the other side  
displays the inbox.


How do you do 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 [EMAIL PROTECTED]


NSTableView Question

2008-08-02 Thread Eric Lee
I have two table views with two different data, and I have two buttons  
so that when you press one button, something is added to the first  
table view, and when you press the second button, some info is added  
to the second table view. You can't press the 1st one to add it to the  
2nd table view.


So, here's my question. How do you have two table view's in the  
same .h/.m file? I try to reimplement the needed protocols, but I  
can't, so I then try to add the code to adding data to the same  
protocols that the 1st table view is implementing, but then, both  
table view's stop working!


Does anyone have any suggestions?
___

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

Please do not post admin requests or moderator comments to the list.
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 [EMAIL PROTECTED]


NSDate, NSTimer, NSTimeInterval combined question

2008-08-01 Thread Eric Lee
I'm making a StopWatch, and I'm just a beginner, so please be patient  
with me.


I have two tabs. The first tab is a timer, while the second tab is a  
clock in string format. I have a few problems with both of them.


The problem with the timer is that it starts from January 1st, 2001.  
How can I modify my code so that it'll start from 0, and then go  
upwards (1, 2, 3, 4, 5, 6, 7, etc...)?


I'll post my code below.

The problem with the clock is that it can post the time in string  
format, but it won't update every minute after that. I also use  
awakeFromNib to post it, because, like i said, I'm just a beginner  
(first programming language also).


Here's the code for the timer:

- (IBAction)startWatch:(id)sender

{
NSDate *currentDate = [NSDate date];

	timer = [NSTimer timerWithTimeInterval:0 target:self  
selector:@selector(updateTextfield:) userInfo:nil 			repeats: YES];
	[[NSRunLoop currentRunLoop] addTimer:timer forMode:  
NSDefaultRunLoopMode];

[timer setFireDate:currentDate];
[timer retain];
}


- (void)updateTextfield:(NSTimer *)timer

{

NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];

NSTimeInterval startTime;

NSTimeInterval difference = now - startTime;

NSString *timeString = [NSString stringWithFormat:@%f, difference];

[textField setStringValue:timeString];
}


Here's the code for the clock:

- (void)awakeFromNib
{
NSDate *someDate = [NSDate date];
NSTimer *anotherTimer = [NSDate date];

[clock setStringValue:anotherTimer];
}


Thanks to everyone!
___

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

Please do not post admin requests or moderator comments to the list.
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 [EMAIL PROTECTED]


Growl, NSTimer, and Launching Application help!

2008-07-21 Thread Eric Lee
I've written a stopwatch application so that I can get to know  
NSTimer, NSAlert, how to implement growl, etc.


Problem 1:

I've fully implemented growl, but how can you implement growl so that  
you can disable and enable growl by unchecking/checking a checkbox  
because too many small windows appearing might get a little annoying.


Problem 2:

The stopwatch application launches from January 1st, 2001, because I  
implemented
-timeIntervalSinceReferenceDate, because -timeIntervalSinceDate, and - 
timeIntervalSinceNow, wouldn't work. I don't know how to change the  
application so that it WILL work with those two. Basically, how do I  
change my code so that when I start the timer, it'll start from 0, and  
then go up?


Problem 3:

For some reason, when I quit the application, and then click on the  
icon on the dock, it won't open another window. How do you fix 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 [EMAIL PROTECTED]


StopWatch Application Help

2008-07-20 Thread Eric Lee
I'm trying to make a stopwatch application, and I'm having trouble  
getting the Timer to fire, and then having the Text field being updated.


Here's the code:

AppController.h


@interface AppController : NSObject {
IBOutlet NSTextField *textField;
NSTimer *timer;
NSDate *startTime;
}

- (IBAction)startWatch:(id)sender;
- (IBAction)stopWatch:(id)sender;

---

AppController.m

---

#import AppController.h


@implementation AppController

- (IBAction)startWatch:(id)sender
{
NSDate *currentDate = [NSDate date];
NSString *string = [timer value];
	timer = [NSTimer timerWithTimeInterval:1 target:self  
selector:@selector(startWatch:) userInfo:nil repeats: YES];

[timer isValid];
[textField setValue:string];
	[[NSRunLoop currentRunLoop] addTimer:timer forMode:  
NSDefaultRunLoopMode];

[timer setFireDate:currentDate];
}
- (IBAction)stopWatch:(id)sender
{
[timer invalidate];
[timer release];
}

@end

---

I know that there is definitely some mistakes, as this is my first  
time using NSTimer, and NSTimeInterval (i'm trying to learn this class  
for another application).


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 [EMAIL PROTECTED]


NSTimer, and NSTimeInterval help?

2008-07-19 Thread Eric Lee
I'm planning on making a stopwatch where the timer fires and then the  
text field updates by each second.


I read online that I should use NSTimeInterval for this, as well as  
NSDate, and NSTimer.


My main question is, how do you use NSTimeInterval?

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 [EMAIL PROTECTED]


Array help!

2008-07-17 Thread Eric Lee
I'm doing Challenge from Chapter 6 in the 3rd edition of the Cocoa  
Programming for mac OS X book, and I've ran into some trouble.


While I'm trying to reload data, there's always this warning the says:

Warning: 'NSScrollView' may not respond to '-reloadData' (Messages  
without a matching method signature will be assumed to return 'id' and  
accept '...' as arguments)


 I have no idea what it means, and no idea how to correct it.

here's the code:

App Controller.m

-

#import AppController.h


@implementation AppController

- (id) init
{
[super init];
array = [[NSMutableArray alloc] init];

return self;
}

- (NSInteger)numberOfRowsInTableView:aTableView
{
return [array count];
}

- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(NSInteger)rowIndex
{
return [array objectAtIndex:rowIndex];
}

- (void)tableView:(NSTableView *)anotherTableView
   setObjectValue:(id)anObject
   forTableColumn:(NSTableColumn *)anotherTableColumn
  row:(NSInteger)rowIndex
{
[array replaceObjectAtIndex:rowIndex withObject:anObject];
}

- (IBAction)addThing:(id) sender
{
NSString *string = [textField stringValue];
NSLog(@Got string %@ from textfield, string);

[array addObject:string];
[tableView reloadData];
}

@end

AppController.h
--

#import Cocoa/Cocoa.h


@interface AppController : NSObject {
NSMutableArray *array;
IBOutlet NSTextField *textField;
IBOutlet NSScrollView *tableView;
}

- (IBAction)addThing:(id)sender;

@end
---

I've connected everything. Also, I think there are other problems,  
since when I press a button that's supposed to add an object into the  
TableView, nothing happens, even though a log appears on the console.


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 [EMAIL PROTECTED]


Challenge Chapter 6 help!

2008-07-16 Thread Eric Lee
First of all, I'm' new to cocoa, so I'm a beginner that just started.  
I'm trying to make the To-Do list on Chapter 6 from Aaron's new book,  
Cocoa Programming for Mac OS X Third Edition.


I've made an NSMutableArray, set the data source of the NSTableView to  
AppController, made an IBACTION and connected it to a Button, made a  
text field, and connected the AppController and the text field, and  
made an outlet for the table view, and connected it to the app  
controller.


For the .m file, I used:

NSString *string = [textField stringValue];
[array insertObject:string atIndex:0];

Then I got stuck


Help please?
___

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

Please do not post admin requests or moderator comments to the list.
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 [EMAIL PROTECTED]


Chapter 6 Challenge Help!

2008-07-16 Thread Eric Lee
First of all, I'm' new to cocoa, so I'm a beginner that just started.  
I'm trying to make the To-Do list on Chapter 6 from Aaron's new book,  
Cocoa Programming for Mac OS X Third Edition.


I've made an NSMutableArray, set the data source of the NSTableView to  
AppController, made an IBACTION and connected it to a Button, made a  
text field, and connected the AppController and the text field, and  
made an outlet for the table view, and connected it to the app  
controller.


For the .m file, I used:

NSString *string = [textField stringValue];
[array insertObject:string atIndex:0];

Then I got stuck


Help please?
___

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

Please do not post admin requests or moderator comments to the list.
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 [EMAIL PROTECTED]


NSMutableArray help

2008-06-27 Thread Eric Lee
For practice (and I¹m a beginner...reading Aaron Hillegass¹ book), and I¹m
trying to complete one of his challenges in his Third Edition.

In that challenge, you are supposed to make a to-do list.

My question is, how do you add an object to a NSMutableArray, and then have
to array display it?

The book has a hint about a method, -replaceObjectAtIndex:withObject:. How
do you implement that?

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 [EMAIL PROTECTED]


NSString help!

2008-06-25 Thread Eric Lee
I¹m trying to get a string from one text field and then set the string in
another text field.

How do you do 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 [EMAIL PROTECTED]