我需要将enum作为一个整体与一个字符串进行比较,以便检查枚举的全部内容.
想要的东西:
NSString *colString = [[NSString aloc] initWithString:@"threeSilver"];
typedef enum {
oneGreen,
twoBlue,
threeSilver
}numbersAndColours;
if (colString == numbersAndColours) {
//Do cool stuff
}
Run Code Online (Sandbox Code Playgroud)
但很明显我不能这样做,也许是一个结构......对不起,我是C的新手请帮忙吗?
顺便说一句:我知道NSString不是C,但认为这个问题比Obj-C更多.
谢谢
我有一个问题让人头疼,我只是创建方法:
-(void) main{
for (int i = 0; i< 100;i++) {
[self getPhoneOfContact:i];
}
}
-(void)getPhoneOfContact:(NSInteger)id_contact {
ABRecordRef record = ABAddressBookGetPersonWithRecordID(addressBook,id_contact);
CFTypeRef ref1;
ref1 = ABRecordCopyValue(record,kABPersonPhoneProperty);
CFRelease(record);
CFRelease(ref1);
}
Run Code Online (Sandbox Code Playgroud)
我认为内存将近似常数,因为我已经复制了释放内存,但实际上它仍然会增加每个循环i; 谁能解释一下这个:(谢谢!
我有页面控制但没有导航到其他视图.所以请提供解决方案.
pageControl=[[UIPageControl alloc] initWithFrame:CGRectMake(0,380,320,40)];
pageControl.backgroundColor=[UIColor clearColor];
pageControl.userInteractionEnabled =YES;
[pageControl addTarget:self action:@selector(pageAction:) forControlEvents:UIControlEventValueChanged];
[pageControl setHighlighted:YES];
-(void)pageAction:(UIPageControl*)control
{
[self displayNextPage];
[self displayPreviousPage];
}
Run Code Online (Sandbox Code Playgroud)
谢谢,Madan Mohan.
我需要有关UIPickerView的帮助,在我的应用程序中,我必须在可用的国家/地区显示UIPickerView.如果任何机构已经实施了国家选择器,请分享代码.
谢谢
我在iphone日期选择器中遇到了本地化的问题.我希望日期选择器只用英语显示日期,但现在它需要在iphone设置中设置为该区域的语言.我尝试了各种有用的东西,如下所示.
通过代码设置语言环境
NSLocale* locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"];
[datePicker setLocale:locale];
[datePicker setCalendar:[locale objectForKey:NSLocaleCalendar]];
Run Code Online (Sandbox Code Playgroud)这没用.如果有任何人有好的想法来解决这个问题,请帮忙
我在使用时收到了弃用方法的警告
[buttonLeft setLineBreakMode:UILineBreakModeWordWrap];
Run Code Online (Sandbox Code Playgroud)
这种方法还有其他替代品吗?
链接错误:
ld: duplicate symbol _OBJC_METACLASS_$_Reachability in /Users/jmf/Documents/iOS Development/jmf_Client/jmf/jmf/ww_libs/libmfcbroem_ios.a(Reachability.o) and /Users/tpf/Library/Developer/Xcode/DerivedData/jmf-erlknghfcpoomnfanzovahfacgpv/Build/Intermediates/jmf.build/Debug-iphoneos/jmf.build/Objects-normal/armv7/Reachability.o for architecture armv7
Run Code Online (Sandbox Code Playgroud)
如果我只是删除h/m文件(和相关的导入指令),希望只使用libmfcbroem_ios.a中的Reachability ...链接器会抛出:
Undefined symbols for architecture armv7:
"_kReachabilityChangedNotification", referenced from:
-[MKNetworkEngine initWithHostName:customHeaderFields:] in MKNetworkEngine.o
-[MKNetworkEngine dealloc] in MKNetworkEngine.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
如何告诉链接器使用"a"文件中的Reachability?
(免责声明,我刚刚开始使用ObjC/iOS)
谢谢你的帮助...
将我的应用程序更新为iOS6标准时,纵向/横向消失了.当我使用Xcode 3构建时,Ir工作得很好.但是现在使用最新的Xcode和最新的SDK,旋转消失了,它始终处于纵向模式.无论我在"支持的界面方向"中加入什么.我以前用来获得旋转的代码似乎根本没有效果.我有这些台词.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
switch (toInterfaceOrientation) {
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
return YES;
default:
return NO;
}
}
Run Code Online (Sandbox Code Playgroud)
我如何更改以及如何更改以使其再次运行?
我有两个带有ok/cancel按钮的UIAlertViews.
我通过以下方式捕获用户响应:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,哪个alertView目前正在打开?
在每个单击确定/取消时,我有不同的操作...
我不想将方法作为参数传递给另一个方法,因此它知道在结束运行时调用的方法.可能吗?
[self bringJSON:(NSString *)_passedValua:(NSObject *)anotherMethod];
Run Code Online (Sandbox Code Playgroud) objective-c ×5
iphone ×4
xcode ×3
ios ×2
c ×1
ios4 ×1
ios5 ×1
ios6 ×1
memory-leaks ×1
methods ×1
parameters ×1
uialertview ×1
uibutton ×1
uidatepicker ×1