Skip to content

Commit

Permalink
define function in NSObject.m so that it won't be omitted by clever l…
Browse files Browse the repository at this point in the history
…inkers
  • Loading branch information
rfm committed Jan 19, 2025
1 parent 2cf2b2d commit 9b4965e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 0 additions & 9 deletions Source/NSEnumerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,3 @@ - (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
}
@end

/**
* objc_enumerationMutation() is called whenever a collection mutates in the
* middle of fast enumeration.
*/
void objc_enumerationMutation(id obj)
{
[NSException raise: NSGenericException
format: @"Collection %@ was mutated while being enumerated", obj];
}
10 changes: 10 additions & 0 deletions Source/NSObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@
#endif
#endif

/* objc_enumerationMutation() is called whenever a collection mutates in the
* middle of fast enumeration. We need to have this defined and linked into
* any code that uses fast enumeration, so we define it in NSObject.h
*/
void objc_enumerationMutation(id obj)
{
[NSException raise: NSGenericException
format: @"Collection %@ was mutated while being enumerated", obj];
}

/* platforms which do not support weak */
#if defined (__WIN32)
#define WEAK_ATTRIBUTE
Expand Down

0 comments on commit 9b4965e

Please sign in to comment.