Why my app crashed when called a NSString variable declared globally?
up vote
-2
down vote
favorite
I declared a string variable to be used in another class in the same file, however when I try to display an alert with the string, it crashed.
NSString *str1;
@implementation someClass
-(void) someMethod{
str1 = something; //update the str1 value from .plist
//Alert with str1 in here displayed with no issue
}
@end
Then after the value of str1
is being updated, another class retrieved it as below, here, it crashed
%hook someInterestingClass
%new
-(void) someMethod:(NSNotification*)notification
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Sample Title"
message:str1
delegate:nil
cancelButtonTitle:@"Sample Title"
otherButtonTitles:nil];
[alert show];
[alert release];
}
%end
However if I globally declare a float
like so and display an alert (same with above), it display perfectly fine. Why is NSString
so special?
float someValue;
EDIT:
I realized it only crashed if only I try to access it from under %new
, but not under %hook
objective-c jailbreak
add a comment |
up vote
-2
down vote
favorite
I declared a string variable to be used in another class in the same file, however when I try to display an alert with the string, it crashed.
NSString *str1;
@implementation someClass
-(void) someMethod{
str1 = something; //update the str1 value from .plist
//Alert with str1 in here displayed with no issue
}
@end
Then after the value of str1
is being updated, another class retrieved it as below, here, it crashed
%hook someInterestingClass
%new
-(void) someMethod:(NSNotification*)notification
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Sample Title"
message:str1
delegate:nil
cancelButtonTitle:@"Sample Title"
otherButtonTitles:nil];
[alert show];
[alert release];
}
%end
However if I globally declare a float
like so and display an alert (same with above), it display perfectly fine. Why is NSString
so special?
float someValue;
EDIT:
I realized it only crashed if only I try to access it from under %new
, but not under %hook
objective-c jailbreak
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I declared a string variable to be used in another class in the same file, however when I try to display an alert with the string, it crashed.
NSString *str1;
@implementation someClass
-(void) someMethod{
str1 = something; //update the str1 value from .plist
//Alert with str1 in here displayed with no issue
}
@end
Then after the value of str1
is being updated, another class retrieved it as below, here, it crashed
%hook someInterestingClass
%new
-(void) someMethod:(NSNotification*)notification
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Sample Title"
message:str1
delegate:nil
cancelButtonTitle:@"Sample Title"
otherButtonTitles:nil];
[alert show];
[alert release];
}
%end
However if I globally declare a float
like so and display an alert (same with above), it display perfectly fine. Why is NSString
so special?
float someValue;
EDIT:
I realized it only crashed if only I try to access it from under %new
, but not under %hook
objective-c jailbreak
I declared a string variable to be used in another class in the same file, however when I try to display an alert with the string, it crashed.
NSString *str1;
@implementation someClass
-(void) someMethod{
str1 = something; //update the str1 value from .plist
//Alert with str1 in here displayed with no issue
}
@end
Then after the value of str1
is being updated, another class retrieved it as below, here, it crashed
%hook someInterestingClass
%new
-(void) someMethod:(NSNotification*)notification
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Sample Title"
message:str1
delegate:nil
cancelButtonTitle:@"Sample Title"
otherButtonTitles:nil];
[alert show];
[alert release];
}
%end
However if I globally declare a float
like so and display an alert (same with above), it display perfectly fine. Why is NSString
so special?
float someValue;
EDIT:
I realized it only crashed if only I try to access it from under %new
, but not under %hook
objective-c jailbreak
objective-c jailbreak
edited Nov 17 at 10:38
asked Nov 17 at 10:27
Gregor Isack
440312
440312
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53350323%2fwhy-my-app-crashed-when-called-a-nsstring-variable-declared-globally%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown