本文整理汇总了Python中Foundation.NSString.alloc方法的典型用法代码示例。如果您正苦于以下问题:Python NSString.alloc方法的具体用法?Python NSString.alloc怎么用?Python NSString.alloc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foundation.NSString
的用法示例。
在下文中一共展示了NSString.alloc方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pre_appdata_use_startup
# 需要导入模块: from Foundation import NSString [as 别名]
# 或者: from Foundation.NSString import alloc [as 别名]
def pre_appdata_use_startup(appdata_path):
preload_dlls(unhandled_exc_handler)
try:
DOMAIN = NSString.alloc().initWithString_('com.apple.LaunchServices')
KEYS = (NSString.alloc().initWithString_('LSArchitecturesForX86_64'), NSString.alloc().initWithString_('LSArchitecturesForX86_64v2'))
APP = NSString.alloc().initWithString_('com.getdropbox.dropbox')
UserDefaults = NSUserDefaults.standardUserDefaults()
launchServices = UserDefaults.persistentDomainForName_(DOMAIN)
if launchServices:
for key in KEYS:
apps = launchServices.objectForKey_(key)
if apps and apps.get(APP):
apps.removeObjectForKey_(APP)
UserDefaults.setObject_forKey_(apps, key)
UserDefaults.setPersistentDomain_forName_(launchServices, DOMAIN)
UserDefaults.synchronize()
report_bad_assumption("User had 'Open using Rosetta' set.")
except Exception:
unhandled_exc_handler()
if MAC_VERSION <= LEOPARD:
try:
psn = ProcessSerialNumber()
Carbon.GetCurrentProcess(psn)
TRACE('On Leopard or lower: PSN is %r', (psn.lowLongOfPSN, psn.highLongOfPSN))
except Exception:
unhandled_exc_handler()
return arch.fixperms.check_and_fix_permissions(appdata_path)
示例2: input_box
# 需要导入模块: from Foundation import NSString [as 别名]
# 或者: from Foundation.NSString import alloc [as 别名]
def input_box(title):
box = NSAlert.alloc().init()
box.addButtonWithTitle_(NSString.alloc().initWithString_("OK"))
box.setMessageText_(NSString.alloc().initWithString_(title))
textbox = NSTextField.alloc().initWithFrame_(NSMakeRect(0, 0, 200, 24));
box.setAccessoryView_(textbox)
box.runModal()
return textbox.stringValue()
示例3: volume_list
# 需要导入模块: from Foundation import NSString [as 别名]
# 或者: from Foundation.NSString import alloc [as 别名]
def volume_list(folders, delegate):
volumes = NSMutableArray.alloc().init()
volumes.addObject_(NSString.alloc().initWithString_(os.path.expanduser('~/Ubuntu One')))
volumes.addObject_(NSString.alloc().initWithString_(os.path.expanduser('/Users/jose/Library/Application Support/ubuntuone')))
for folder in folders:
if (bool(folder['subscribed'])):
volumes.addObject_(NSString.alloc().initWithString_(folder['path']))
delegate.returnedVolumeList_(volumes)
示例4: add
# 需要导入模块: from Foundation import NSString [as 别名]
# 或者: from Foundation.NSString import alloc [as 别名]
def add(self, label, uri, index=-1):
if label in self.labels:
return
if index == -1 or index > len(self.items):
index = len(self.items)
elif index < -1:
index = 0
new_item = NSDictionary.alloc().initWithDictionary_(
dict(
Name=NSString.alloc().initWithString_(label),
URL=NSString.alloc().initWithString_(uri)
)
)
self.items.insert(index, new_item)
self.labels.append(label)
示例5: __normalize_path_batch
# 需要导入模块: from Foundation import NSString [as 别名]
# 或者: from Foundation.NSString import alloc [as 别名]
def __normalize_path_batch(self, paths):
pool = NSAutoreleasePool.alloc().init()
try:
results = []
for path in paths:
assert isinstance(path, unicode)
s = NSString.alloc().initWithString_(path).autorelease()
ret = s.fileSystemRepresentation()
results.append(ret.decode('UTF-8'))
return results
finally:
del pool
示例6: set_user_interface_language
# 需要导入模块: from Foundation import NSString [as 别名]
# 或者: from Foundation.NSString import alloc [as 别名]
def set_user_interface_language(code):
if platform == 'mac':
from Foundation import NSAutoreleasePool, NSString, NSUserDefaults
arp = NSAutoreleasePool.alloc().init()
s = NSString.alloc().initWithString_(APPLE_LANGUAGES)
defaults = NSUserDefaults.standardUserDefaults()
if code == '':
TRACE('Setting language defaults to system language.')
defaults.removeObjectForKey_(s)
else:
TRACE('Updating language defaults to %r.', code)
defaults.setObject_forKey_([code], s)
defaults.synchronize()
示例7: _mac_get_system_languages
# 需要导入模块: from Foundation import NSString [as 别名]
# 或者: from Foundation.NSString import alloc [as 别名]
def _mac_get_system_languages():
assert platform == 'mac'
from Foundation import NSAutoreleasePool, NSString, NSUserDefaults
arp = NSAutoreleasePool.alloc().init()
s = NSString.alloc().initWithString_(APPLE_LANGUAGES)
try:
from pymac.helpers.core import get_preference
langs = list(get_preference('com.apple.systempreferences', APPLE_LANGUAGES))
TRACE('_mac_get_system_languages real: %r', langs)
return langs
except Exception:
unhandled_exc_handler()
langs = NSUserDefaults.standardUserDefaults().get(s)
TRACE('_mac_get_system_languages from user: %r', langs)
return langs
示例8: get_public_files
# 需要导入模块: from Foundation import NSString [as 别名]
# 或者: from Foundation.NSString import alloc [as 别名]
def get_public_files(public_files, path, delegate):
for public_file in public_files:
if public_file['path'] == path:
delegate.returnedPublicLink_(NSString.alloc().initWithString_(public_file['public_url']))
return None
delegate.returnedPublicLink_(None)
示例9: get_downloads
# 需要导入模块: from Foundation import NSString [as 别名]
# 或者: from Foundation.NSString import alloc [as 别名]
def get_downloads(downloads, delegate):
returnDownloads = NSMutableArray.alloc().initWithCapacity_(len(downloads))
for download in downloads:
returnDownloads.addObject_(NSString.alloc().initWithString_(download['path']))
delegate.returnedDownloads_(returnDownloads)
示例10: get_uploads
# 需要导入模块: from Foundation import NSString [as 别名]
# 或者: from Foundation.NSString import alloc [as 别名]
def get_uploads(uploads, delegate):
returnUploads = NSMutableArray.alloc().initWithCapacity_(len(uploads))
for upload in uploads:
returnUploads.addObject_(NSString.alloc().initWithString_(upload['path']))
delegate.returnedUploads_(returnUploads)
示例11: write
# 需要导入模块: from Foundation import NSString [as 别名]
# 或者: from Foundation.NSString import alloc [as 别名]
def write(self):
self.favoriteservers["Controller"] = NSString.alloc().initWithString_("CustomListItems")
self.favoriteservers["CustomListItems"] = self.items
CoreFoundation.CFPreferencesSetAppValue("favoriteservers", self.favoriteservers, self.id)
CoreFoundation.CFPreferencesAppSynchronize(self.id)