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 7501881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:41:02+00:00 2026-05-29T20:41:02+00:00

//////////////////// Mutation.h #import <Foundation/Foundation.h> @interface Mutation : NSObject @property (assign) NSString *inputString; @property (assign)

  • 0

//////////////////// Mutation.h

#import <Foundation/Foundation.h>
@interface Mutation : NSObject
@property (assign) NSString *inputString;
@property (assign) NSString *outputString;    
@end

//////////////////// Mutation.m

#import "Mutation.h"
@implementation Mutation
@synthesize inputString;
@synthesize outputString;
@end

//////////////////// NTAppDelegate.h

#import <Cocoa/Cocoa.h>
#import "Mutation.h"
@interface NTAppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@property (weak) IBOutlet NSTextField *dataField;
@property (weak) IBOutlet NSTextField *outputField;
@property (assign) Mutation *mutation;
- (IBAction)receiveUserTextFromTextField:(NSTextField *)sender;
@end

//////////////////// NTAppDelegate.m

#import "NTAppDelegate.h"
#import "Mutation.h"
@implementation NTAppDelegate
@synthesize window = _window;
@synthesize dataField = _dataField;
@synthesize outputField = _outputField;
@synthesize mutation = mutation;    //statement #1

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification //#3 (block)
{
Mutation *aMutation = [[Mutation alloc] init];
[self setMutation:aMutation];
[aMutation setInputString:@"new"];
[aMutation setOutputString:@"old"];
NSLog(@"Mutation inputString is %@; outputString is %@", [aMutation inputString], [aMutation outputString]);    
}

- (IBAction)receiveUserTextFromTextField:(NSTextField *)sender   //#2 (block)
{
// assign the user's entered text to Mutation's inputString
NSString* newText = [sender stringValue];   // -stringValue inherited from NSControl
NSLog (@"%@ was entered", newText);         //  <-THIS WORKS
[mutation setInputString:newText];           //  <-CRASH  statement #4 (crashes)
NSLog(@"Mutation(2) inputString is %@; outputString is %@", [aMutation inputString], [aMutation outputString]);    
}

@end

/////// I am using ARC. Trying to get a handle inductively on objC fundamentals. This is a continuation of my first question…

My specific questions refer to the numbered code lines/blocks (#1-#4) above.

1 is this the creation of an instance of Mutation that is global?

2 do I need to pass a ref to this mutation here? and if so,
by putting another argument in function?

3 I do not understand why when built and run, logging occurs from first from block #3, then block #2

4 why does this line crash (log says unrecog selector)

Log:

when program loads, log records, in order:

a) user data goes here… was entered

b) Mutation(2) inputString is (null); outputString is (null)

c) Mutation inputString is new; outputString is old

then, if user enters data (statement #4):
bad things happen.

  • 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-29T20:41:03+00:00Added an answer on May 29, 2026 at 8:41 pm
    1. @synthesize will generate ivar mutation, -mutation, and -setMutation: for you, nothing more than that. The creation of an instance is done in alloc and init.
    2. Yes and No. You should make your code clear which mutation you were referring to, by ivar/accessor method, rather than another argument. Once signature changed, the method no longer exists like before.
    3. You made a mistake defining your @property (assign) Mutation *mutation. The app delegate bears the ownership of ivar mutation and therefore is responsible for retaining it. What you need is @property (strong) Mutation *mutation.
    4. You defined mutation to be a weak ivar, so the setter -setMutation: would not retain it, and it was released when block #3 ends. When the #4 is reached, mutation has been released, and the address the ivar pointing at is probably allocated to other object instances, which is obviously not a kind of Mutation, therefore the error occurred.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#import Mutation.h //my class @implementation NTAppDelegate using app delegate as controller @synthesize window =
With reference to the following link: http://docs.python.org/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe I wanted to know if the following:
Some Genetic Algorithm frameworks, such as http://www.aforgenet.com/ requires many parameters, such as mutation rate,
Is it harder (or impossible) to implement mutation testing in some languages than others?
How is mutation done in Ruby for this: row = row.to_hash I've tried row.to_hash!
I'm working on a mutation algorithm for a homework project and I'm stumped at
Using the python/thrift interface I am trying to insert a SuperColumn just like the
Since DOM mutation is marked as deprecated by the w3c (see http://www.w3.org/TR/DOM-Level-3-Events/#events-mutationevents ), is
I'm using this mapper created by Ikai Lan: package com.ikai.mapperdemo.mappers; import java.util.Date; import java.util.logging.Logger;
What is mutation in cassandra? What is it doing? i didnt find any full

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.