Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 697471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:10:17+00:00 2026-05-14T03:10:17+00:00

From Notification Watcher source. – (void)selectNotification:(NSNotification*)aNotification { id sender = [aNotification object]; [selectedDistNotification release];

  • 0

From Notification Watcher source.

- (void)selectNotification:(NSNotification*)aNotification {
id sender = [aNotification object];
[selectedDistNotification release];
selectedDistNotification = nil;
[selectedWSNotification release];
selectedWSNotification = nil;
NSNotification **targetVar;
NSArray **targetList;
if (sender == distNotificationList) {
    targetVar = &selectedDistNotification;
    targetList = &distNotifications;
} else {
    targetVar = &selectedWSNotification;
    targetList = &wsNotifications;
}
if ([sender selectedRow] != -1) {
    [*targetVar autorelease];
    *targetVar = [[*targetList objectAtIndex:[sender selectedRow]] retain];
}
if (*targetVar == nil) {
    [objectText setStringValue:@""];
} else {
    id obj = [*targetVar object];
    NSMutableAttributedString *objStr = nil;
    if (obj == nil) {
        NSFont *aFont = [objectText font];
        NSDictionary *attrDict = italicAttributesForFont(aFont);
        objStr = [[NSMutableAttributedString alloc] initWithString:@"(null)"
                                                        attributes:attrDict];
    } else {
/* Line 1 */        objStr = [[NSMutableAttributedString alloc] initWithString:
                    [NSString stringWithFormat:@" (%@)", [obj className]]];
        [objStr addAttributes:italicAttributesForFont([objectText font])
                        range:NSMakeRange(1,[[obj className] length]+2)];
        if ([obj isKindOfClass:[NSString class]]) {
            [objStr replaceCharactersInRange:NSMakeRange(0,0) withString:obj];
        } else if ([obj respondsToSelector:@selector(stringValue)]) {
            [objStr replaceCharactersInRange:NSMakeRange(0,0)
                                  withString:[obj performSelector:@selector(stringValue)]];
        } else {
            // Remove the space since we have no value to display
            [objStr replaceCharactersInRange:NSMakeRange(0,1) withString:@""];
        }
    }
    [objectText setObjectValue:objStr];
/* LINE 2 */    [objStr release];
}
[userInfoList reloadData];

}

Over at //LINE 2 objStr is being released. Is this because we are assigning it with alloc in //LINE 1?

Also, why is //LINE 1 not:

objStr = [NSMutableAttributedString* initWithString:@"(null)"
                                                    attributes:attrDict]

If I create a new string like

(NSString*) str = [NSString initWithString:@"test"];
...
str = @"another string";

Would I have to release str, or is this wrong and if I do that I have to use [[NSString alloc] initWithString:@”test”]?
Why isn’t the pointer symbol used as in [[NSString* alloc] …?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:10:18+00:00Added an answer on May 14, 2026 at 3:10 am

    It is being released because it was allocated. The alloc has the effect of a retain and must be balanced by a release (or autorelease). Pretty much any method that begins with init results in an object that needs to be released. It is all about balancing the retains with the releases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently got a notification from a McAfee service (what used to be called
im want to send notification from my server side (c#) via urbanairship api is
i want to know that when we want to use push notification service.From where
Problem: Event notifications (From COM object - Server) are not received as listed in
When I've registered an object foo to receive KVO notifications from another object bar
I want to send a notification from a UITableViewController-A to UITableViewController-B. I was adding
i get device insertion and removal notification from WM_DEVICECHANGE i get the dbcc_name from
Can you display a message box (or any form of notification) from a windows
I would like to call an android dialog box from Notification bar in android
I am sending Push notification from PHP to iPhone. Connection was established successfully but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.